ASP.NET validation

I am working on a form for which I would like to use validation functions such as This . Does this have to be done on clients? or server side? I know to use some of the MS ajax controlds, however at what point do I show the message at the top?

I hope I explained myself.

0


source to share


5 answers


You have to check at both ends.

  • Client side to provide feedback, immediately so that users can respond quickly (bonus for them) and you save server resources (bonus for you).

  • Make sure that any non-JS user agents can validate the input. This is important in order to prevent malicious / corrupted data from entering your system.



If you're just going to do this, make it server-side, but there are significant user benefits by implementing a dual system.

+3


source


on the client side and provide feedback when they hit the submit button

but since you cannot trust client side validation and also server side validation and display feedback on postback if things are wrong.



but since you cannot trust the calling code, also check with the database server (stored procedures are best) and return errors back to the calling code if something is wrong.

this way you covered all bases

0


source


It is generally considered good practice to validate both client-side and server-side ... in case someone tries to directly submit a POST form without actually loading the page.

As far as displaying the validation message is concerned, this is a personal preference. I kind of try to give feedback as soon as possible, so I'll do things like regex validation when a field loses focus.

0


source


Actually, you can use ASP.NET Validation controls, you can use them both client-side and server-side.

Check out these resources:

0


source


In general (depending on the quality of your Ajax Framework) there is no client side validation. This is a relic from the past (Pre Ajax Times) and is no longer needed ...

Run your entire check on the server. After all, everything is 100 times faster with Ajax, right ...?

0


source







All Articles