【问题标题】:Customize the default message for a rule [duplicate]自定义规则的默认消息 [重复]
【发布时间】:2010-11-07 14:58:36
【问题描述】:

有没有办法为 jQuery Validate 插件中的无效规则自定义默认消息?

我的意思是像

每当需要一个字段时,我 没有指定自定义消息, 消息应该是“自定义消息”

我试过这段代码,但没有成功

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

【问题讨论】:

  • jQuery 的验证插件不止一个;你说的是哪一个?
  • 对不起。我说的是http://bassistance.de/jquery-plugins/jquery-plugin-validation/

标签: jquery jquery-validate


【解决方案1】:
jQuery.extend(jQuery.validator.messages, {
  required: "custom message",
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-18
    • 2018-09-04
    • 2018-08-19
    相关资源
    最近更新 更多