Checkbox Validation using CustomValidator

<script type="text/javascript"> 
     function IsChecked(sender, args) { 
         if (document.getElementById('<%= AgreeTermsConditionsCheckBox.ClientID  %>').checked) { 
             args.IsValid = true; 
         } 
         else { 
             args.IsValid = false; 
         } 
     } 
 </script>


<asp:CheckBox ID="AgreeTermsConditionsCheckBox" runat="server" />  
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Please check this box." Display="Dynamic" ClientValidationFunction="IsChecked" > 
</asp:CustomValidator>

No comments:

Post a Comment