In the examples for the jQuery Validate plugin, I see three different approaches to declaring validation rules:
- CSS Classes -- e.g.
<input type="text" name="whatever" class="required" />
- Attributes -- e.g.
<input type="text" name="whatever" required />
- JS code -- e.g.
$("#myForm").validate({ rules: { whatever: "required", ... } });
But I don't see anywhere in the docs that explains why you'd use one over the other. Nor do I see an explanation of how to use the validation methods with each approach (for example, how would you use the "max( value )" method with a tag attribute or a css class?).
What are the tradeoffs between these three approaches? And how exactly do you declare all the different validation methods using each approach?