开发者

Customize the default message for a rule [duplicate]

开发者 https://www.devze.com 2023-01-24 09:18 出处:网络
This question already has answers here: jQuery validation: change default error message 开发者_运维知识库(15 answers)
This question already has answers here: jQuery validation: change default error message 开发者_运维知识库 (15 answers) Closed 3 years ago.

Is there a way to customize the default message for an invalid rule in jQuery Validate plugin?

I mean something like

whenever a field is required, and I have not specified a custom message, the message should be "custom message"

I have tried this code but without success

$.validator.setDefaults({
    messages: { 
        required: "custom message"
    }
});


jQuery.extend(jQuery.validator.messages, {
  required: "custom message",
});
0

精彩评论

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