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.
BamaErnAsked:
Who is Participating?
 
Alpesh PatelConnect With a Mentor Commented:
hi
you can use the ValidationGroup attribute for controls
you can the value of  three textbox's attribute as value/none on click event of associated checkbox
all that textbox are associated with commandbutton through which u are going to validate them.

button is validate only those textbox which has ValidationGroup attibute......

thats it

thanx
0
 
Joel CoehoornDirector of Information TechnologyCommented:
You'll have to use custom validators for the textboxes.
0
 
BamaErnAuthor Commented:
Why?  Is there an article or another thread you can point me to?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
BamaErnAuthor Commented:
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.)
0
 
BamaErnAuthor Commented:
Guess it handles the link automatically.  Nice.
0
 
BamaErnAuthor Commented:
Simpler than the method I came up with.  This is better than my solution so I'm giving you the points.
0
All Courses

From novice to tech pro — start learning today.