<script type="text/javascript">
jQuery(function(){
jQuery("#agree").validate({
expression: "if (!isChecked(SelfID)) return false; else return true;",
message: "Please agree the terms and conditions"
});
});
</script>
<form>
<input type="checkbox" value="agree" name="agree" id="agree" />
<input type="submit">
</form>
答案 0 :(得分:2)
您需要将验证添加到表单元素,并将所需规则设置为复选框
<form id="myform">
<input type="checkbox" value="agree" name="agree" id="agree" />
<input type="submit">
</form>
然后
jQuery(function ($) {
$("#myform").validate({
rules: {
agree: {
required: true
}
},
messages: {
agree: "Please agree the terms and conditions"
}
});
});
演示:Fiddle