开发者

How to assign an error message when adding css class validation rule

开发者 https://www.devze.com 2023-01-22 23:06 出处:网络
I have added a css class validation rule for jquery validator as follows: jQuery.validator.addClassRules({

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消