Question

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?

Was it helpful?

Solution

I'd avoid using an alert box. It's annoying, requires an extra click, and since it's modal - stops the entire browser.

Instead, highlight the erroneous fields/values, and print a message at the top, explaining that the highlighted fields need to be corrected before the user can continue.

You can use Asp.Net validation, or jQuery form validation - both work equally well.

OTHER TIPS

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.

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.

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.

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top