【发布时间】:2019-01-12 00:14:28
【问题描述】:
这是我现在拥有的东西: 我有一个复选框,我需要验证它是否被选中。
<input type="checkbox" name="person_info_check" value="0" &nbps>Read and agree!</input>
但是当我尝试使用我在互联网上搜索的方式时,我发现我无法抓住复选框并因此验证。
这就是我抓取复选框的方式:
if($('#person_info_check').is(':checked')){
if(confirm("Are you sure to submit?")){
return true;
}
else return false;
}
else{
alert("Please read the file and agree the statement!");
return false;
}
我也试过这个:
var checkbox = document.getElementsByName("person_info_check");
if(checkbox[0].checked==false){
alert("Please read the file and agree the statement!");
return false;
}
【问题讨论】:
-
&nbps应该是什么? -
您的
confirm(...")缺少开场白
标签: javascript jquery checkbox forms