need help on custom validation
-
I need to do 1 client side validation: 1. if the checkbox is checked, the corresponding TextBox must not be empty. 2. The TextBox field must be empty if the chcekbox is not checked how do i use the custom validation with javascript to accomplish that? thanks in advance
-
I need to do 1 client side validation: 1. if the checkbox is checked, the corresponding TextBox must not be empty. 2. The TextBox field must be empty if the chcekbox is not checked how do i use the custom validation with javascript to accomplish that? thanks in advance
Hi there, You can provide your own validation function at the client side in the
ClientValidationFunction
property of the CustomValidator[^]. Also you should remember that if you set theControlToValidate
property of the validator to the tetxbox control, then the validator will skip your own custom validator when the textbox is empty. So you don't need to set this property and leave it empty. In your own validation function, you can provide a snippet of script to check thechecked
property of the checkbox and thevalue
of the input textbox control. You can also wrap everything up in your own custom validator, for more information see Developing a Validator Control[^]