AND in expressions?
AND in expressions?
Hi,
I'm using jQuery's expression language to define dependencies in my
validation plugin. For example, to specify that a field is required
only when some checkbox is checked, you'll write:
rules: {
name: {
required: "#checkbox:checked"
}
}
Using the comma seperator it is possible to specify OR rules, eg.
"#required:checked, #optional:checked" returns "true" if either or
those two is checked.
So far I haven't found a way to specify AND logic, eg.
"#required:checked & #optional:checked" isn't supported. Of course
you'd have to ask what that query would usually return, because I'm
just hijacking it to return true or false. In that example, it could
return both elements if they are both checked, or none if they aren't
checked. Usually you'd select that in two steps: $("#required,
#optional").filter(":checked"). That isn't very handy when used within
validation dependency rules.
Any idea how a AND could be implemented (or avoided)?
-- Jörn