How do I use jQuery validator to add/remove a classname (e.g. validate) on the form element’s parent <li> so I can style everything related to that element by only setting the one classname?
The markup is
<li class="validate">
<label for="product">Product of interest <abbr title="Required field">*</abbr></label>
<input id="product" type="text" name="product" value="" placeholder="e.g. school bench" class="required" minlength="2">
<!-- Hidden by CSS unless parent has 'validate' class -->
<label for="product" class="description">Please name a product.</label>
</li>
and the default jQuery is
$("#commentForm").validate();
Use the
highlightandunhighlightoptions here to override where theerrorClass(orvalidClass) gets applied:By default, the
errorClassis “error” and get applied directly on the input element. For a better illustration, this is the default validate functions, when you don’t provide these options to.validate(), here’s what happens: