Return to Snippet

Revision: 45317
at April 28, 2011 12:31 by housecor


Updated Code
public void ValidateChecked(object sender, ServerValidateEventArgs e)
		{
			e.IsValid = chkMyChkBox.Checked;
		}

//Client side method, referenced in customvalidtor ClientValidationFunction attribute:
<script type="text/javascript" language="javascript">
function ValidateCheckboxIsChecked(sender, args)
{
args.IsValid = (document.getElementById("CheckBox1").checked);
}
</script>

Revision: 45316
at April 28, 2011 12:30 by housecor


Updated Code
public void ValidateChecked(object sender, ServerValidateEventArgs e)
		{
			e.IsValid = chkMyChkBox.Checked;
		}

//Client side method:
<script type="text/javascript" language="javascript">
function CustomValidator1_ClientValidate(sender, args)
{
args.IsValid = (document.getElementById("CheckBox1").checked);
}
</script>

Revision: 45315
at April 28, 2011 11:22 by housecor


Updated Code
public void ValidateChecked(object sender, ServerValidateEventArgs e)
		{
			e.IsValid = chkMyChkBox.Checked;
		}

Revision: 45314
at April 28, 2011 11:17 by housecor


Initial Code
public void ValidateChecked(object sender, ServerValidateEventArgs e)
		{
			CheckBox chkBox = sender as CheckBox;
			e.IsValid = chkBox.Checked;
		}

Initial URL


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

Initial Title
Require checkbox via customvalidator

Initial Tags


Initial Language
C#