单击按钮时跳过选项卡上的验证

时间:2015-02-17 15:53:23

标签: jquery html forms jquery-validate

我在选项卡上验证表单的字段以及单击“提交”按钮时验证表单本身。我正在使用Jquery验证器插件。我在表单上有另一个按钮,我用来返回列表。当我点击“返回列表”按钮时,第一个字段得到验证,我收到错误消息,我必须再次单击“返回列表”取消创建。现在,我想这是因为我在模糊上验证关于如何规避这个问题的任何想法。

HTML

   <div class="form-group text-center">
            <button type="submit" id="Submit" class="btn btn-primary">Submit</button>
            <button type="reset" id="Reset" data-bind="click: reset" class="btn btn-primary">Reset</button>
            <a id="BacktoIndex" href="/Provider/ShowTheListOfProviders" class="btn btn-primary cancel">Back to List</a>
        </div>

JQUERY验证码是

 $("#providerDetailsForm").validate({
    onfocusout: function (element, event) {
        this.element(element);
    },
    onkeyup: function (element, event) {
        if (event.which === 9 && this.elementValue(element) === '') {
            return;
        } else if (element.name in this.submitted) {
            this.element(element);
        }
    },
    rules:
        {
            contactNumber: { required: true, minlength: 10, maxlength: 10 },
            contactEmail: { required: true, acceptEmail: true }
        },
    messages: {
        contactNumber: {
            required: "Please enter the Contact Number",
            minlength: "Minimum of 10 digits required.",
            maxlength: "Maximum of 10 digits allowed."
        },
        contactEmail: {
            required: "Please enter the Email Address",
            acceptEmail: "Please enter a valid email ID"
        }
    }
});

0 个答案:

没有答案