0

Is it possible to change the CSS class of the validated control if it's not valid without codebehind or just with less code ex. Set automatic CSS class to "invalid" of all textboxes which have a required field validator?...

I don't like to make a check for each validator (isvalid) I have, manually.

Thank you and best regards

Marc
  • 2,659
  • 3
  • 34
  • 41

1 Answers1

0

What you need is client side validation.

JQuery is perfect for that. you can use this nice tutorial: http://www.webreference.com/programming/javascript/jquery/form_validation/

or use a plugin: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

one way or another - no need to run to the server and back, and you have full control of the validation process and its outcomes (so you can change the css accordingly)

Enjoy!

David Salzer
  • 872
  • 1
  • 7
  • 24
  • Thank you I will try. I hoped I can override anything to make automatic by the default asp validation check – Marc Jan 03 '10 at 13:06
  • I think this is a poor answer as you end up having to duplicate all your validation rules client and server side, an alternative approach is available on http://stackoverflow.com/questions/196859/change-text-box-color-using-required-field-validator-no-extender-controls-please – mattmanser Jun 06 '11 at 13:26