views:

152

answers:

3

So I have a couple of forms done in asp.net/c# that I need to validate. If one of the validators fails, I’d like to change the class for the text box and the label on the client side/post back. The way I’d usually do this is by manually validating the forms client side and server side. Is there a way to do this using validators instead of a bunch of if statements?

A: 

Generally speaking this is precisely what validators are for. But the client-side validation may not necessarily just change the field's class (presumable to change its colour). How important is that way of indicating a validation problem?

mfloryan
A: 

The Required Field Validator Extender control is what you want.

John Rasch
+1  A: 

You can use the standard asp.net validators for the client side that will potentially give you some text next to the field or within the validation summary. There are some 3rd party plugins that you might be able to utilize that will take this a step further in regards to custom CSS styling, etc.

Take a look at these alternatives to the .NET validators:

RSolberg