jQuery.validator.addClassRules()

jQuery.validator.addClassRules( name, rules )

Description: Add a compound class method – useful to refactor common combinations of rules into a single class.

Examples:

Example: Add a new compound rule called “name”, replacing class=”required” minlength=”2″ with class=”name”.

1
2
3
4
jQuery.validator.addClassRules("name", {
required: true,
minlength: 2
});

Example: Add two compound class rules for name and zip.

1
2
3
4
5
6
7
8
9
10
11
12
jQuery.validator.addClassRules({
name: {
required: true,
minlength: 2
},
zip: {
required: true,
digits: true,
minlength: 5,
maxlength: 5
}
});