I needed a generic "required if visible" rule for use with the jQuery Validation plugin. This is the result:
required:"#myinput:visible"could have worked, but ":visible" doesn't check for hidden parents, and I didn't want to repeat the element selector.
- ":hidden" is false for elements with the "visibility:hidden" CSS rule, so I couldn't use ":not(:hidden)" either.
- Technique for checking element visibility from Remy Sharp's blog.