jQuery 验证:表单被验证两次

jQuery Validate: Form is Being Validated Twice

我有一个正在使用的表单 jQuery Validate 来验证表单。我运行陷入了一个问题。该表单正在验证两次。我的变量 'isValid' 在

之后两次记录到控制台

触发验证的按钮是类型按钮

<button type="button" name="submit" id="submit" vclass="btn btn-default">Submit</button>

下面是 JavaScript,其中包含要向用户显示的规则和消息。它还包括按钮的点击事件。

$(function () {
$("#createUser").validate({
    rules: {
        FirstName: "required",
        email: {
            required: true,
            minlength : 2
        },
        zipCode: {
            required: true,
            maxlength : 5
        },
        Telephone: {
            required: function (element) {
                return $('#options option:selected').val() != "1";
            },
            maxlength : 12
        },
        options: {
        required: true,
        notEqual: "1"
        }
    },
    messages: {
        FirstName: "Please specify your first name",
        email: {
            required: "This email field is required.",
            minlength : "email had to have a min length of 2."
        },
        zipCode: {
            required: "Zip code is a required field.",
            maxlength : "zip code cannot be more than 5 characters."
        },
        Telephone: {
            required : "Telephone is a required field.",
            maxlength : "Phone number has to have a max length of 12 characters."
        },
        options: {
            required: "Option is a required field",
            notEqual: "Select a different option"
        }
    }
  });

jQuery.validator.addMethod("notEqual", function (value, element, param) {
    return this.optional(element) || value != param;
}, "Please specify a different (non-default) value");


  $('#submit').on('click', function () {
     isValid = $('#createUser').valid();
     console.log(isValid);
  });
});

我发现的大多数与两次验证表单相关的问题都与使用类型提交而不是按钮有关。另外,我不会在我的 JavaScript 文件中的任何地方调用提交。我在这里错过了什么?

如果规则在单独的 js 中,确保脚本没有被引用两次,