I have added a css class validation rule for jquery validator as follows:
jQuery.validator.addClassRules({
requiredDatepicker: {
required: true,
date: true开发者_如何学运维
}
});
However, when doing this I get the default error messages. How can I assign custom error messages when using addClassRules()?
See the Refactoring rules section on how to add custom messages.
You can't do this generally with the rule set, since class rules are just combinations of basic rules (for example even required
is really required: { required: true }
underneath) and those have the error messages. To get custom errors you'll have to set them per-element, or use the meta-data plugin to put the rules on the element directly.
精彩评论