使用jQuery验证检查复选框

使用jQuery验证检查复选框,jquery,validation,jquery-plugins,Jquery,Validation,Jquery Plugins,我的表单中有一个输入类型的复选框,我想使用jQuery验证: 我的其他十几种表单都可以很好地使用它,但这些表单都没有复选框。如何检查以确保使用此插件选中复选框 目前,我有以下内容: ... termsConditions: { required: true } ... <input type="checkbox" id="termsConditions" name="termsConditions"/> I agree to the <a href="terms"&g

我的表单中有一个输入类型的复选框,我想使用jQuery验证:

我的其他十几种表单都可以很好地使用它,但这些表单都没有复选框。如何检查以确保使用此插件选中复选框

目前,我有以下内容:

...
termsConditions: {
    required: true
}
...

<input type="checkbox" id="termsConditions" name="termsConditions"/> I agree to the <a href="terms">terms and conditions</a>
<label style="float: none;" for="termsConditions" class="error" generated="true"></label>
。。。
条款条件:{
必填项:true
}
...
我同意这个建议
当我尝试验证它时,什么都没有发生。有什么帮助吗?

使用
“必需的”

或者您可以简单地将类
“required”
添加到复选框中

<input type="checkbox" id="termsConditions" class="required" name="termsConditions"/>


另一个可能的原因可能是复选框字段不可见。将跳过对任何隐藏输入的验证

如果您想让它验证隐藏字段,可以将“忽略”选项设置为其他
ignore:“hidden'

$('#form').validate({
    ignore: []
});

@Sennheiser使用
“required”
或添加类
“required”
应该可以工作,如果不行,请发布更多html和
.validate()
选项,查看是否有其他原因导致问题。我知道发生错误的原因。我在复选框前面有另一个表单,这可能会混淆验证程序。我切换了表单和复选框的顺序,现在可以了。是否可以添加自定义消息?@MarkColeman复选框下方的红色验证消息如何?当您使用自定义样式输入时,这可能就是问题所在。完美答案
$('#form').validate({
    ignore: []
});