BamaErn
asked on
Optional Validators - Is this possible?
I have a form with three checkboxes at the top and four textboxes below them. If the first checkbox is not checked, the first textbox is required. If the second checkbox is not checked, the second and third textboxes are required. If the third checkbox is checked, the fourth textbox is required. My problem is how to validate them. If I put a required field validator on all of the checkboxes, the validation expects all four textboxes to have data, regardless of the state of the checkboxes. If I use the checkbox code to disable (enable = false) the individual validators as required, the validation summary no longer displays. And I'm not even sure that this is a valid approach.
Any ideas or nudges in the right direction would be greatly appreciated.
Any ideas or nudges in the right direction would be greatly appreciated.
You'll have to use custom validators for the textboxes.
ASKER
Why? Is there an article or another thread you can point me to?
ASKER
I found a solution. I can disable the appropriate validators BUT I have to set both .enabled = false and .EnableClientScript = false. The non-appearing summary was a red herring in that it was incorrectly placed in a div that had it's visible set to false under certain conditions.
This article confirmed to me that I could do this: http://msdn2.microsoft.com/en-us/library/bt244wbb(VS.80).aspx. (Sorry, not sure how to embed a link.)
This article confirmed to me that I could do this: http://msdn2.microsoft.com/en-us/library/bt244wbb(VS.80).aspx. (Sorry, not sure how to embed a link.)
ASKER
Guess it handles the link automatically. Nice.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Simpler than the method I came up with. This is better than my solution so I'm giving you the points.