I’m am trying to write some special validating code for a client. I want to string several selectors together in the find function in jquery is this possible?
I am trying to say for example, in the fieldsets that are currently visible, find all the input fields with type=text and that have the class “-required”, also find all the textarea field that also have the class “-required”.
I am trying this, but it’s not working, it only picks the Textarea fields
var reqButEmpty = $('fieldset:visible')
.find('input[type="text", class*="-required",textarea[class*="-required"]')
.filter(function()
You can, but not in the manner that you’re attempting
To get the “and” behavior, we use two separate “attribute” selectors on the same element selector.
Then we use the
,multiple selector to get the “or” behavior for thetextarea.I’m also assuming that
-requiredis part of a class name, and not the entire thing. Some HTML reference would be helpful.