I have three textboxes and I want to validate them. At least one textbox must contain data.
How can I do this?
(The textboxes are Home Phone No., Work Phone No., Mobile No. and I need to check at least one method of contact is specified)
I have three textboxes and I want to validate them. At least one textbox must contain data.
How can I do this?
(The textboxes are Home Phone No., Work Phone No., Mobile No. and I need to check at least one method of contact is specified)
Use a Custom Validator, there is no need to cycle through the text boxes on the page as this approach gets ALL of the text boxes on the page. The JavaScript function specified in the
ClientValidationFunction
will be called for each text box with a validator associated with it.the above function dont validate that at least one textbox contains data it validate that the control attached to the validator have data. Just use one custom validator like this
In case you want to reuse the function you can add attributes to your validation object. Check it out: http://alejandrobog.wordpress.com/2009/09/27/pass-your-own-arguments-to-the-clientvalidationfunction-in-a-customvalidator/
Use a Custom validator, with ClientValidationFunction property to this function.