开发者

jQuery Validation: style "valid" fields

开发者 https://www.devze.com 2023-03-07 12:36 出处:网络
I\'m using jQuery Validation and I know how to style the \"invalid fields\". However, I also want to开发者_运维技巧 style the \"valid fields\".

I'm using jQuery Validation and I know how to style the "invalid fields". However, I also want to开发者_运维技巧 style the "valid fields".

Is there some way to do it using the jQuery Validation plugin?

Thanks!


You can use like this

$ ("#form1").validate({        

    highlight: function (element, errorClass) {
        $(element).css({ "background-color": ErrorClass });
    },

    unhighlight: function (element, errorClass) {
        $(element).css({ "background-color": SuccessClass });            
    }
});


According to the docs, a valid class is added to elements that have been validated and are considered valid. This can be set by the validClass option:

http://docs.jquery.com/Plugins/Validation/validate#toptions

0

精彩评论

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