View Full Version : Javascript Alert Msg

07-12-2005, 12:16 AM

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-12-2005, 12:26 AM
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, 07: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, 04: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