Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Alert Msg

    Hi,

    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?

    Thanks,

    The Edge

  • #2
    New Coder
    Join Date
    Jun 2005
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    Code:
    alert('date is not valid, please enter a valid date!');
    form_name.field_name.value=''; 
    form_name.field_name.focus();

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Quote Originally Posted by Burgerking63
    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.

  • #4
    New Coder
    Join Date
    Jun 2005
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •