jquery - 问题 - 在 jQuery 验证插件中输入有效数据和错误数据时,成功类不会消失

标签 jquery html css jquery-validate

我在输入有效数据时遇到了这样的问题,没关系

但在那之后,当我输入错误的数据时,会出现这种情况:

这是我的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/

相关文章:

html - iOS设备上的CSS填充/边距问题

javascript - 如何使用 ionic 框架显示 RSS feed 中的图像

html - 当 SMS 应用程序未在后台运行时,无法在 iPhone 上的 SMS 链接中预填充电话号码和消息正文

css - HTML5 对 CSS 相对和绝对定位的更改

python - 如何以自定义方式呈现 CheckboxGroup(或任何其他元素)?

javascript - 如何访问从 Javascript 函数中的 Controller 传递的 HTML 模板参数

php - 如何将 jquery 中的值存储到 php 变量中?

javascript - Sweet Alert Woocommerce 添加到购物车确认

javascript - 我如何在数据表中搜索 - 使用 ajax/服务器端加载数据

html - 我应该如何在html中包含√E?我要 E 上的水平符号