views:

345

answers:

6

I have a web form with more than 10 fields that are submitted to the database. So before submitting the values I am doing JavaScript validation.

Currently I am using JavaScript validation and shows an alert box if an error occurs in data entry.

Is it a good practice to show alert box when JavaScript validation fails or should I use asp.net validation controls to display the error messages?

+4  A: 

ASP.NET Validation controls are more recommended, because the alert can be intrusive. They can be set to give messages without posting back, which is ideal.

Just make sure you make it obvious when the form has failed.

Noon Silk
+6  A: 
Traveling Tech Guy
Was just about to post similar answer! This, is my eyes, is always the better way to go rather than popping up alert boxes.
James
There's nothing I hate more than submitting a form, trying to switch to a different tab, and getting no response, because there's an alert dialog somewhere (by now, usually below my browser's window, necessitating an alt+tab to bring to front) saying something like "zip code missing". Easier to put a red border around the zip code field, issue a message at the top and require the user to re-submit...
Traveling Tech Guy
A: 

A good practice is what when your code supports fall back method. For example, if Javascript is disabled then the user should still be able to view the error messages, if any.

More over, they dont look as good as you could style your own divs and display them after some server side validation .. and then use javascript to hide/fade out this error message container div.

Wbdvlpr
A: 

I think its a personal/design preference.

Sometimes its just more obvious when there is a javascript alert indicating something needs to be done. Sometimes a small red asterisk gets lost on the page.

Mark Redman
+1  A: 

from the usability perspective it is much better to use .net validation. Depending on your alert box implementation you may bombard user with many alerts which is very bad.

Also don't rely on client side validation only. Be sure to validate on the server side as well. And this is where .net validation might be handy again.

DmitryK
A: 

In my own opinion, alert boxes are just too annoying to see on websites these days since they're all you see on Windows... But, if you prefer a better looking site, use something else. If you want to make sure the message gets across - then use an alert.

baeltazor