views:

156

answers:

5

Hi, I am working on a form, which I would like to validation features like This. Should this all be done on clientside? or server side? I am aware of using some of MS ajax controld, however, at what point do I display the message at the top?

I hope I explained myself.

+3  A: 

You should validate at both ends.

  • Client side to make sure feedback is immediate so users can complete it fast (a bonus for them) and you save server resources (bonus for you).

  • Server side to make sure that any user-agents not using JS can check the incoming data. This is essential to stop malicious/corrupt data entering your system.

If you were only going to do one, make it server side, but there are considerable benefits to the user by implementing a dual-system.

Oli
A: 

validation on the client-side and provide feedback when they click the submit button

but since you cannot trust client-side validation, also validation on the server side and display feedback on postback if everything is not correct

but since you cannot trust the calling code, also validate in the database server (stored procedures are best) and raise errors back to the calling code if something is amiss

that way you've covered all the bases

Steven A. Lowe
A: 

It's generally considered a good practice to validate on both the client side and the server side...just in case someone attempts to directly submit a form POST without actually loading a page.

As far as when to display the validation message, it is something of a personal preference. I tend to perfer giving feedback as soon as possible, so I would do things like regex validation when the field looses focus.

ckramer
A: 

Its really easy, you can use the ASP.NET Validation controls, you can use them in both, client and server side.

Check this resources:

CMS
Can I interact with the validations controls, i.e. catching the error event and then displaying my error message at the top?
Saif Khan
A: 

In general terms (depending upon the quality of your Ajax Framework) client-side validation is out. It's a relic from the past (Pre Ajax Times) and not really needed anymore...

Run all your validation on the server. After all with Ajax everything is 100 times as fast anyway, right...?

Thomas Hansen