Validating checkboxes in asp net Adult cam froggy live only web

Hi, I am having a problem validating a checkbox in my form that has several Required Field Validator controls and a Validation Summary control. Validation for the checkbox is done using a custom validation contol and this does not work. The code is as follows: Don't address the control that you are validating directly in the validation code - that's the point of the Control To Validate member. From that you should be able to figure out what the problem is with your IF condition.Sub Validate Terms(By Val sender As Object, By Val args As Server Validate Event Args) If CType(Me. Find Control("Terms Of Use"), Check Box) Then args. Is Valid = False End If End Sub I get the error Value of type 'System. To answer the most frequently occurring complaint against this question: "checkboxes can have two legitimate states - checked and unchecked", this is an "I accept the terms and conditions..." checkbox which must be checked in order to complete a registration, hence checking the box is required from a business logic standpoint. Please provide complete cut-n-paste ready code fragments with your response! Server Validate Event Args) Handles Custom Validator1. If you set a validation control's , stating: "Control 'control ID' referenced by the Control To Validate property of 'validation Control ID' cannot be validated." There may be times, however, when you need to provide validation for a Check Box or Check Box List.Many Web pages with Terms of Service include a Check Box titled "I agree to the above terms" that must be checked before continuing.

validating checkboxes in asp net-68validating checkboxes in asp net-61

Thanks, Laura Hi Laura, You should be using the Checked property of the Check Box control. Checked Then Hope this helps to solve your problem Good Luck [yes] Regards Vineed thanks, i can't believe I spent so much time on that.

I know there are several pieces to this -- the Custom Validator (presumably), the code-behind, some javascript and possibly a check for Is Valid, and the frustrating part for me is that in each example I've seen, one of these critical pieces is missing!

The Custom Validator parameter for the javascript function name should be ' Client Validation Function', not ' On Client Validate'. Checked End Sub Protected Sub Custom Validator1_Server Validate(By Val source As Object, By Val args As System.

If you're just doing one box, it's better to do it with IDs. Checked End Sub Protected Sub chk Age Validator_Server Validate(By Val sender As Object, By Val e As System.

This example does it by specific check boxes and doesn't require j Query. Server Validate Event Args) _ Handles chk Agree Validator.

When I copied and pasted your code into a html file and ran it, my FF and IE spat out an error.

You must have an account to comment. Please register or login here!