Validation of check box is little bit tricky but you can validate with Java Script
Add this script in the page.
<script type="text/javascript">add a Checkbox Control
function validateCheckBox(source,args)
{
var cb=document.getElementById("Privacy1");
if(!cb.checked)
args.IsValid=false;
}
</script>
Now you need to add a custom Validator:-<asp:CheckBox ID="Privacy1" runat="server"></asp:CheckBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator" ValidateEmptyText="True" ClientValidationFunction="validateCheckBox"></asp:CustomValidator>
No comments:
Post a Comment