jQuery验证showError块突出显示

时间:2016-03-17 12:42:38

标签: javascript jquery jquery-validate

在我的网站上,我需要在表单中使用验证,但表单中有标签。运行.validate()时,我想highlight无效输入并弹出一条摘要消息,说明您遇到问题,然后转到X标签进行修复。 showErrors似乎阻止highlight方法

弹出作品,highlight没有。删除showErrorhighlight投放

这是我的代码:

$("#frmMyForm").validate({
    onclick: false,
    onkeyup:false,
    ignore: ":disabled",
   rules: {

        PasswordExpiryDays: { required: true, number: true, min: 30, max: 90 },
        PasswordStrength: { required: true, number: true, min: 10, max: 50 }

    },
    messages: {

        PasswordExpiryDays: {
            required: " This can't be left blank",
            min: "Please enter a number between 30 and 90",
            max: "Please enter a number between 30 and 90"
        },
          PasswordStrength: {
            required: " This can't be left blank",
            min: "Please enter a number between 10 and 50",
            max: "Please enter a number between 10 and 50"
        }

    },

   showErrors: function (errorMap, errorList) {
       //code for error message pop-up
    }
});

1 个答案:

答案 0 :(得分:1)

好,包括

this.defaultShowErrors();
showErrors上的

修复了问题