简体   繁体   中英

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. 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 .​

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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