【问题标题】:jquery validator plugin ignore title attribute to show error messagejquery 验证器插件忽略标题属性以显示错误消息
【发布时间】:2012-07-11 18:15:43
【问题描述】:

如何忽略标题属性以在 jquery 验证器插件中显示错误消息。因为我使用该标题来显示工具提示而不是错误消息。

插件初始化

$('#participantform').validate();

要验证的表单元素

<input name="o_phone_cnt" class="inputtextie required digits" title="Country Code" style="width:25px" type="text" minlength="1" size="3" maxlength="3"/>

点击按钮

$('#sendmail_ppnt').button().click(function(){
      $('#participantform').submit();
});

在验证时它显示错误消息为 必需,但在将标题添加到 input:text 元素后它显示 国家代码 作为错误消息。

如何配置验证器插件以忽略标题属性以显示错误消息。

【问题讨论】:

    标签: jquery jquery-validate


    【解决方案1】:

    您可以将ignoreTitle 选项传递给validate()

    $("#participantform").validate({
        ignoreTitle: true
    });
    

    顺便说一句,请注意文档说(强调我的):

    从title属性中设置跳过阅读消息,有助于避免 Google 工具栏的问题;为了兼容性,默认为 false, message-from-title 将来可能会被完全删除 释放

    因此,您可能无需任何操作即可通过插件的未来版本获得所需的行为。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-19
      • 1970-01-01
      • 1970-01-01
      • 2012-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多