Why isn't my form submit button not going to a next page when I click on it?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dseals22
    New Member
    • Jan 2017
    • 74

    Why isn't my form submit button not going to a next page when I click on it?

    Hello, I am trying to figure out why the form's "submit this form" button is not taking me to another HTML page I specified in the attribute and not only that but when I put wrong first names, email addresses, and order numbers, and date of orders, it doesn't return JavaScript messages I specified in my if-else codes using JavaScript. Can someone please help me out with my problem by telling what I did wrong or guiding to a solution to my problem? Here is the Javascript codes I use on the form. Here is the Javacript code below:
    Code:
    var $ = function (id)
    {
      return document.getElementById(id); 
    }
    
    var submitForm = function()
    {
       var FirstName= $("firstName").value;
       var OrderNumber= $("orderNumber").value; 
       var DateOfOrder= $("date_of_order").value;
       var emailAddress= $("email_address").value; 
       var isValid=true;
        
       if(FirstName !== "Cherry", "Micheal", "Sandra", "Cookie")
       {
          $("firstname_error").firstChild.nodeValue=
           "This person does not exist.";
           isValid=false;
        } else{ $("firstname_error").firstChild.nodeValue="";}
        
      if(OrderNumber !== 3134, 4234, 9234, 3566)
      {
         $("orderNumber_error").firstChild.nodeValue="Invalid Order Number.";
         isValid=false;
       } else{ $("orderNumber_error").firstChild.nodeValue="";}
    
      if(DateOfOrder !== 12-07-23, 15-04-24, 16-02-01, 14-01-12)
      {
        $("date_of_order_error").firstChild.nodeValue="Date doesn't exist in
        system";
        isValid=false;
      } else{ $("date_of_order_error").firstChild.nodeValue="";}
      
      if(emailAddress !="cherryjackson@gmail.com", "michealroberts@yahoo.com",
       "sandrabell@hotmail.com", "cookiedanny@outlook.com")
      {
        $("email_address_error").firstChild.nodeValue="The email doesn't exist";
         isValid=false;
      } else{ $("email_address_error").firstChild.nodeValue="";}
       if(isValid)
         {
    	   //submit the form if all entries are valid
    	    $("cookie_form").submit();
         }
    }
    window.onload = function()
      {
        $("form_submission").onclick = submitForm;	
         $("email_address").focus(); 
      }
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    The only choice you have is using your browser's dev tool to check for errors and if there are none checking that every variable is what you expect and that the control flow happens as you expect.

    Comment

    Working...