how to use jquery validation on specific fields only
In my form I have 4 fields when I'm using jquery validation on form id by default it valida开发者_如何学运维tes all the fields. I want validation on 1 mandatory field only.
My jquery is as below
jQuery.noConflict();
jQuery(document).ready(function(){jQuery("#add-color-form").validate(
{
rules: {
color_name: {
required:true,
maxlength: 20
},
},
messages: {
color_name: {
required: "Please enter color name",
maxlength: "Not more than 20 characters"
},
}
}
);
}
Still it validates all the fields while I want validation only on 1 field
add-color-form is my form id
Its difficult to tell from the code you've supplied, make sure your inputs dont have a 'required' class and maybe bet one of the examples working first, then adjust that?
精彩评论