1. 使用验证控件验证checkbox是否选中
<asp:CustomValidator ID="cv1" runat="server" ErrorMessage="请选择同意此项" ClientValidationFunction="CheckCBL" SetFocusOnError="true"></asp:CustomValidator>
<script type="text/javascript">
function CheckCBL(source, args) {
var result = true;
$("input[name*='chbAgree']").each(function () {
if (!$(this).attr('checked')) {
result = false;
}
});
args.IsValid = result;
return;
};
</script>
<script type="text/javascript">
function CheckCBL(source, args) {
var result = true;
$("input[name*='chbAgree']").each(function () {
if (!$(this).attr('checked')) {
result = false;
}
});
args.IsValid = result;
return;
};
</script>