我有三个输入单选按钮,例如
<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'
}
}
问题是它在第一次输入单选按钮后显示错误消息,并且我的布局被破坏。
最佳答案
使用错误放置
errorPlacement: function (error, element) {
error.insertBefore(element);
}
关于javascript - jQuery 验证消息问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29816545/