我在输入有效数据时遇到了这样的问题,没关系
但在那之后,当我输入错误的数据时,会出现这种情况:
这是我的js代码,与错误/有效类相关:
errorElement: "div",
wrapper: "div", // a wrapper around the error message
errorPlacement: function(error, element) {
element.before(error);
offset = element.offset();
error.css('right', offset.right);
},
success: "valid"
和CSS代码:
label.error{
color:#b76b6f;
width: 200px;
height: 60px;
text-align: right;
position: absolute;
margin-left: 280px;
margin-top: -20px;
margin-bottom: 0;
background: url('../images/not_valid.png') no-repeat;
background-position:100% 80%;
}
div.error{
color:#b76b6f;
width: 200px;
height: 60px;
position: absolute;
margin-left: 180px;
margin-top: -25px;
display: block;
background-color:#F3E6E6;
background: url('../images/not_valid.png') no-repeat;
background-position:100% 100%;
text-align: right;
}
在这种情况下生成的 HTML:
<div class="field2"><label for="user_password">Password</label>
<div class="valid"></div>
<div><div for="passworrd" generated="true" class="error" style="display: block;">Please enter at least 6 characters.</div></div>
<input type="password" size="30" name="user[password]" id="passworrd" class="passwords error"></div>
最佳答案
我认为这就是 focusCleanup
选项的用途。
编辑:
尝试使用 validClass: "valid"
而不是 success: "valid"
。
关于jquery - 问题 - 在 jQuery 验证插件中输入有效数据和错误数据时,成功类不会消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12596285/