Custom validator para validar un checkbox


/ Published in: VB.NET
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2. function ValidateCheckBox(sender, args) {
  3. if (document.getElementById("<%=chkAcepto.ClientID %>").checked == true) {
  4. args.IsValid = true;
  5. } else {
  6. args.IsValid = false;
  7. }
  8. }
  9. </script>
  10.  
  11. <asp:CheckBox ID="chkAcepto" runat="server" Checked="false" />
  12. <asp:CustomValidator ID="reqCheckBox" runat="server" ErrorMessage="Obligatorio"
  13. ClientValidationFunction = "ValidateCheckBox" />

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.