I have 2 textbox controls where date values will be entered. I want it so that if a date is entered into one of the textboxes then the other one becomes required.
This is probably a real noobie question but any help would be greatly appreciated.
Thanks in advance.
Edit: Just to clarify a bit better. I use a compare validator to check if the value entered into the textboxes are dates, so thats not a problem. The problem is that I want some validation so that if a value is entered into one textbox then the other one becomes required. Otherwise if both textboxes are left empty then neither are required.
Well, you could do one of two things. First, as danish said, use the textchanged property of textbox1 to set the Enabled property of validator2 to true or false accordingly. Just make sure you set the autopostback property of textbox1 to true. This would look even better if you wrapped it in an update panel so the user didn’t have to see the autopostback.
The other option is to use a custom validator control where you write the validation logic in the ServerValidate() event. Then, you can check if the text entered in textbox1 is a date and then validate textbox2 accordingly.