As the Shadow Wizard said, at least you can remove the unnecessary :not([type=hidden]) in different places where it doesn't matter ( select and textarea ).
I do not see a problem with the result:
var requiredFields = el.querySelectorAll( "input[required]:not(:disabled):not([readonly]):not([type=hidden])" + ",select[required]:not(:disabled):not([readonly])"+ ",textarea[required]:not(:disabled):not([readonly])");
... not least because it passes it all to the selector engine to take advantage of any optimization that it can do.
Alternatively, you can give all the relevant inputs a common class, and then use:
var requiredFields = el.querySelectorAll( ".the-class[required]:not(:disabled):not([readonly]):not([type=hidden])");
... but I'm not sure that he buys you a lot.
Please give me a good resource for the querySelectorAll function.
There is a specification . MDN is also usually a good place for this material.
Tj crowder
source share