View Full Version : Javascript Alert Msg

07-11-2005, 11:16 PM

I created a javascript validation in .net for the user to receive an alert if they entered an invalid date. The user gets the msg, but the code behind continues and redirects them to the new page trying to use an invalid date. Should the alert have stopped the processing or is their something I need to do?


The Edge

07-11-2005, 11:26 PM
Set up a condition IF/ELSE statement that redirects them to the page only if they enter a correct date. If its invalid, have it do nothing and alert the user that what they entered is incorrect. An alert does not stop actions from happening, but only "pauses" a function to alert the user of something. Once they click "OK", the function continues to run.

If you do alert the user their date is invalid, it is beneficial to have it clear the invalid date and focus on the field to allow them to enter a new one. For example:
alert('date is not valid, please enter a valid date!');

07-12-2005, 06:17 AM
it is beneficial to have it clear the invalid date
Not really. If the user just have a small typo, it is annoying that the input is cleared and he needs to enter it all over again.

07-12-2005, 03:13 PM
I suppose you could have it select as well, just personal preference really ;) . If people cant follow a format the first time, they should be punished. just kidding