判断HTML中的checkbox是否被选中

时间:2021-05-27 21:02:32
      //合法性验证
function checkValidity() {
var userNameCheck = $("#userNameCheck").attr('checked');
var dateCheck = $("#dateCheck").attr('checked');
var descCheck = $("#descCheck").attr('checked');
if (!userNameCheck && !dateCheck && !descCheck) {
alert("至少要勾选一个");
return false;
}
return true;
}
    var checkUserName = $("#checkUserName").is(":checked");
var checkOperateTime = $("#checkOperateTime").is(":checked");
var checkdescriptionInclude = $("#checkdescriptionInclude").is(":checked");
if (!checkUserName && !checkOperateTime && !checkdescriptionInclude) {
alert("至少选择一种条件查询");
return;
}