control focus, clear and validation
Posted on 2008-06-10
I have a form with textbox, dropdown and radiobutton controls. When the user submits the data, I need the form to validate the data.
Now, I know I can use alert messages or labels for it; but I want the error messages to be dynamic. What I have done is that I've decided to shwo the error in the textboxes or highlight the controls themselves when the data is wrong or not entered. To do this all for all the controls is a bit tedious though. Is there any "shortcut" method where I can define the color and highlighting for all the controls which contain invalid data?
Secondly, I want that when the user tries to focus on the controls to enter the correct information, all the highlighting and error should disappear. Again, to do this for all the controls is proving to be a bit complicated. Is there any easier method to write the code for the 'disappearing act' for all the controls the user focuses on at once?
I'm using ASP.Net.
I even tried CSS; but being novice, I couldn't really make it work that way.