javascript - jQuery 验证消息问题

标签 javascript jquery

我有三个输入单选按钮,例如

<input type="radio" name="specific_parent" id="parent_one" class="radio" value="existing_parent"><label class="redio_label" for="existing_parent">Existing Parent</label>
<input type="radio" name="specific_parent" id="parent_two" class="radio" value="prospective_parent"><label class="redio_label" for="prospective_parent">Prospective Parent</label>
<input type="radio" name="specific_parent" id="parent_third" class="radio" value="other"><label class="redio_label" for="other">Other</label>

我已经应用了这样的 jQuery 验证:

rules: {
   specific_parent: {
      required: true
   }
},
messages: {
  specific_parent: {
      required: 'Please select radio button'
  }
}

问题是它在第一次输入单选按钮后显示错误消息,并且我的布局被破坏。

enter image description here

最佳答案

使用错误放置

 errorPlacement: function (error, element) {
      error.insertBefore(element);
}

关于javascript - jQuery 验证消息问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29816545/

相关文章:

javascript - 如何使用html5 localstorage存储列表的顺序?

javascript - 使 tablesorter 表缩小以适合页面

javascript - React Player 和加载多个 URL 源

javascript - 如何在JQuery中动态更改行的Id

jquery - 为什么 'mapify.js' 在 Google Chrome 上不起作用

javascript - 使用 Jquery 删除原始文本

java - 将neo4j数据集连接到Web应用程序的最简单方法是?

javascript - 如何使用 Ctrl+Z 事件将文本替换为星号?

javascript - 如何使用javascript通过api在我的谷歌应用程序脚本中运行一个函数

javascript - 在 Div 内滚动不起作用?