Write the code in .aspx page as follows…
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" language="javascript">
function ClientValidationForCheckBox(sender, args) {
var CheckBox1 = document.getElementById("<%=CheckBox1.ClientID %>")
if (CheckBox1.checked == true) {
args.IsValid = true;
} else {
args.IsValid = false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Please Select CheckBox"
ClientValidationFunction="ClientValidationForCheckBox"></asp:CustomValidator>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
OutPut
Comments on: "How to validate CheckBox Using Custom Validator" (1)
[...] Click this Link to get Solved Code Share this:TwitterFacebookEmailLinkedInLike this:LikeBe the first to like this. [...]