SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with piece of code

    I want the following piece of code to check if a user has submitted a valid number for tickets. It displays the alert if value=0 or "" but it still continues onto the next page. How does continue to the next page till the user inputs a valid number for tickets.

    function VerifyForm() {

    var strFormName = document.frmselect;

    if ( document.frmselect.tickets.value == 0 || document.frmselect.tickets.value =="")
    {

    alert("Either you have not requested any tickets, or have entered a 0.");
    exit();
    }


    else {
    strFormName.submit();
    return true;
    }
    }

  2. #2
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I assume you are calling your function using the onSubmit event handler of the form?

    If so then if you use onSubmit="return VerifyForm();" and you return false from VerifyForm instead of exit (What does exit do anyway?)
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel


Bookmarks

Posting Permissions

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