By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,853 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,853 IT Pros & Developers. It's quick & easy.

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

P: 74
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:
Expand|Select|Wrap|Line Numbers
  1. var $ = function (id)
  2. {
  3.   return document.getElementById(id); 
  4. }
  5.  
  6. var submitForm = function()
  7. {
  8.    var FirstName= $("firstName").value;
  9.    var OrderNumber= $("orderNumber").value; 
  10.    var DateOfOrder= $("date_of_order").value;
  11.    var emailAddress= $("email_address").value; 
  12.    var isValid=true;
  13.  
  14.    if(FirstName !== "Cherry", "Micheal", "Sandra", "Cookie")
  15.    {
  16.       $("firstname_error").firstChild.nodeValue=
  17.        "This person does not exist.";
  18.        isValid=false;
  19.     } else{ $("firstname_error").firstChild.nodeValue="";}
  20.  
  21.   if(OrderNumber !== 3134, 4234, 9234, 3566)
  22.   {
  23.      $("orderNumber_error").firstChild.nodeValue="Invalid Order Number.";
  24.      isValid=false;
  25.    } else{ $("orderNumber_error").firstChild.nodeValue="";}
  26.  
  27.   if(DateOfOrder !== 12-07-23, 15-04-24, 16-02-01, 14-01-12)
  28.   {
  29.     $("date_of_order_error").firstChild.nodeValue="Date doesn't exist in
  30.     system";
  31.     isValid=false;
  32.   } else{ $("date_of_order_error").firstChild.nodeValue="";}
  33.  
  34.   if(emailAddress !="cherryjackson@gmail.com", "michealroberts@yahoo.com",
  35.    "sandrabell@hotmail.com", "cookiedanny@outlook.com")
  36.   {
  37.     $("email_address_error").firstChild.nodeValue="The email doesn't exist";
  38.      isValid=false;
  39.   } else{ $("email_address_error").firstChild.nodeValue="";}
  40.    if(isValid)
  41.      {
  42.        //submit the form if all entries are valid
  43.         $("cookie_form").submit();
  44.      }
  45. }
  46. window.onload = function()
  47.   {
  48.     $("form_submission").onclick = submitForm;    
  49.      $("email_address").focus(); 
  50.   }
  51.  
  52.  
  53.  
  54.  
  55.  
Feb 3 '17 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
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.
Feb 6 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.