<form name="step1" ...>
<input type="text" name="name" required="required"/>
<!-- ... -->
<input type="checkbox" name="acceptTerms1" required="required"/>
<input type="checkbox" name="acceptTerms2" required="required"/>
</form>
正在验证名称字段,但这两个复选框只是被忽略。
我还尝试为他们手动设置规则:
$('form[name="step1"]').validate({
ignore: ":hidden:not(.force-validation, .force-validation :input)", //Not ignoring checkboxes (just for information)
//...
rules: {
"acceptTerms1": 'required',
"acceptTerms2": 'required'
}
});
但规则仍然被忽略。可能会遗漏什么?
答案 0 :(得分:0)
规则应该像这样应用:
rules: {
acceptTerms1: {
required: true
}
acceptTerms2: {
required: true
}
}