简体   繁体   中英

Change styling of error messages for jQuery validation plugin

有没有办法改变jQuery验证表单插件的错误消息的颜色,字体等?

Using that plugin, you can also specify whatever class you want to be used for the error state.

$('.selector').validate({
    errorClass: 'newError'
});

There are also highlight and unhighlight options that allow for more complicated styling to be applied to the element containing the error, such as:

$('.selector').validate({
    highlight: function(element, errorClass) {
        $(element).fadeOut(function() {
            $(element).fadeIn();
        });
    }
});

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

If you are using the bassistance.de plugin there is an associated class with each of the warnings popup. So all you would need to do is css changes to these classes. label.warning or label.error would be the selector to be able to change the styling for warnings. I was able to figure this out by firebugging the warnings that popup on one of the demos for this plugin.

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