Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.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,我在使用jquery validate.js的表单中有三个字段: <input type="text" id="StartDate" name="StartDate"><br /> <input type="text" id="EndDate" name="EndDate"><br /> <label for="AllDate"><input type="checkbox" name="AllDate" id="AllDate"&

我在使用jquery validate.js的表单中有三个字段:

<input type="text" id="StartDate" name="StartDate"><br />
<input type="text" id="EndDate" name="EndDate"><br />
<label for="AllDate"><input type="checkbox" name="AllDate" id="AllDate">All Dates</label>
我也没有幸创建自定义验证规则。寻找一个更好的方法,一个有效的方法!感谢您的帮助。

尝试以下方法:

return !$("#AllDate").is(':checked');
试试这个:

return !$("#AllDate").is(':checked');

这是给你的定制的

if(($("#AllDate").is(':checked')) == true ){
    //Do what you want when all dates are checked

} elseif (($("#StartDate").val()) != "") {
    //Do what you want with StartDate

} else {
    //You have to enter a date

}

快速打字,看看这是否对你有帮助或给你一个基本的想法

if(($("#AllDate").is(':checked')) == true ){
    //Do what you want when all dates are checked

} elseif (($("#StartDate").val()) != "") {
    //Do what you want with StartDate

} else {
    //You have to enter a date

}

快速输入,看看这是否对您有所帮助或提供了一个基本概念

我正在尝试输入整个函数。很好,我提出了这样一个要求:“AllDate:checked”,但这显然与我想要的正好相反。非常感谢我正试着把整个函数打印出来。很好,我提出了这样一个要求:“AllDate:checked”,但这显然与我想要的正好相反。非常感谢