How to add messages to a class with addClassRules
This can be done using below code,
$.validator.messages.accept = 'File must be JPG, GIF or PNG';
$.validator.addClassRules("files", {
accept : "png|jpe?g|gif",
filesize : 2000000
});
In the documentation, the answer is to alias the method that you want to call and add the custom message.
Check the reference under the "Refactoring rules" heading:
// alias required to cRequired with new message
$.validator.addMethod("cRequired", $.validator.methods.required,
"Customer name required");
// alias minlength, too
$.validator.addMethod("cMinlength", $.validator.methods.minlength,
// leverage parameter replacement for minlength, {0} gets replaced with 2
$.format("Customer name must have at least {0} characters"));
// combine them both, including the parameter for minlength
$.validator.addClassRules("customer", { cRequired: true, cMinlength: 2 });