开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜