Posted By

housecor on 04/28/11


Tagged


Versions (?)

Require checkbox via customvalidator


 / Published in: C#
 

RequiredFieldValidator doesn't support checkboxes, but a customvalidator does the trick.

  1. public void ValidateChecked(object sender, ServerValidateEventArgs e)
  2. {
  3. e.IsValid = chkMyChkBox.Checked;
  4. }
  5.  
  6. //Client side method, referenced in customvalidtor ClientValidationFunction attribute:
  7. <script type="text/javascript" language="javascript">
  8. function ValidateCheckboxIsChecked(sender, args)
  9. {
  10. args.IsValid = (document.getElementById("CheckBox1").checked);
  11. }
  12. </script>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: dominhphuoc on April 28, 2011

sdafasdf

You need to login to post a comment.