简体   繁体   English

如何从jquery验证插件中删除默认错误消息

[英]How to remove default error message from jquery validation plugin

$(document).ready(function () {
              $("#frm").validate({
            errorClass:"invalid",
               rules: {
                    cname: { required: true,minlength:5 },
                    cemail: { required: true, email: true }
                }
            });
        });

I am using above function to validate my html form. 我使用上面的函数来验证我的HTML表单。 Validation is working fine. 验证工作正常。 But I want to remove the default error message. 但我想删除默认的错误消息。 I dont want to give any error message, just need to change the background color of the control for which validation fails. 我不想提供任何错误消息,只需要更改验证失败的控件的背景颜色。

You can just give them an empty error message string, like this: 您可以给它们一个空的错误消息字符串,如下所示:

$("#frm").validate({
    errorClass:"invalid",
    rules: {
        cname: { required: true },
        cemail: { required: true, email: true }
    },
    messages: {
        cname: "",
        cemail: ""
    }
});

You can test it out here .​ 你可以在这里测试一下

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM