In the examples for the jQuery Validate plugin, I see three different approaches to declaring validation rules:
From the documentation http://jqueryvalidation.org/rules:
There are several ways to specify validation rules.
- Validation methods without parameters can be specified as classes on the element (recommended)
- Validation methods with parameters can be specified as attributes (recommended)
- Both can be specified as metadata using the metadata plugin [[[note that this is deprecated, so the docs appear to be out of date a bit]]]
- Both can be specified using the rules-option of the validate()-method
https://stackoverflow.com/a/14380401/749227 has some additional useful information.
I prefer using the 'required' attribute over a class, though. I don't find this sort of native attribute support it directly referenced in the documentation, but since it seems like screen-readers would find it more useful than class="required" I go with that in this one case.
As an aside, I'd love to see what other native attributes are respected by the plugin. And info on which of them are picked up by ADTs.