Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery验证多个复选框_Jquery_Jquery Validate - Fatal编程技术网

jquery验证多个复选框

jquery验证多个复选框,jquery,jquery-validate,Jquery,Jquery Validate,我有一些复选框 <input type="check" name="chkOption" id="one" />One <input type="check" name="chkOption" id="two" />two <input type="check" name="chkOption" id="three" />three <input type="check" name="chkOption" id="four" />four 1 二

我有一些复选框

<input type="check" name="chkOption" id="one" />One
<input type="check" name="chkOption" id="two" />two
<input type="check" name="chkOption" id="three" />three
<input type="check" name="chkOption" id="four" />four
1
二
三
四
是否可以使用“jquery.validate”脚本验证“required”此复选框中的任何一个,请尝试以下代码:

$.validator.addMethod("check", function(value, elem, param) {
    if($(".roles:checkbox:checked").length > 0){
       return true;
   }else {
       return false;
   }
},"You must select at least one!");​
看看那里:还有