我想更改jQuery Validate应用于有错误的输入的类
更改此
<input id="firstname" name="firstname" type="text" value="" maxlength="100"
class="error">
到这个
<input id="firstname" name="firstname" type="text" value="" maxlength="100"
class="customErrorClass">
答案 0 :(得分:25)
尝试指定errorClass
属性:
$('.selector').validate({
errorClass: 'customErrorClass',
rules: { ... },
messages: { ... }
});
答案 1 :(得分:0)
对于自定义CSS,可以使用以下代码
<style>
.myErrorCssClass {
border: solid 1px #ff0000;
}
</style>
<script>
$('#form1').validate({
errorClass: "myErrorCssClass",
rules: {
Name: {
required: true,
minlength: 3,
maxlength: 10
},
LastName: {
required: true
}
}
})
</script>