473,387 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

74 64KB
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
1 1143
Dormilich
8,658 Expert Mod 8TB
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

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

Similar topics

3
by: Nick | last post by:
Should be a quickie but I just can't get it to work. I have a form where my users can submit their football picks, when they click submit I would like another sized window to appear...
6
by: Adrian | last post by:
I need to have 2 submit buttons in one form calling the same page. I just need to know which was used. Being able to pass a hidden form input for each would be ideal. How can I do this?? ...
0
by: Dan Sikorsky | last post by:
We're using Remote Scripting to update counters, or colors, displaying on a web page form at a fixed interval, and the form's submit button event handler is executed without clicking the button. I...
4
by: COHENMARVIN | last post by:
I'm a asp programmer starting out with asp.net. I understand that an asp form can post to its own page and that this allows validation of form fields on the server. But suppose all the controls...
7
by: David T. Ashley | last post by:
Hi, For a web page, I want a SUBMIT button that commits the form data and a CANCEL button that goes to a different target (i.e. a different script). I haven't figured out how to do this,...
5
by: Nerry | last post by:
Hello, i'm new to HTML I've created a registration form and have a submit button. i want that if the form is blank and submit is clicked that I could link it to a page saying, "please input...
2
by: dipesh10 | last post by:
I am doing one project with asp net 2.0 and c# ,i have master page and content page , in content page i have 10 text box and one submit button , when submit will click those text box need to...
5
by: sumeetmakkar | last post by:
Hi all, I am a begineer and working on a project. Facing trouble linking a submit buuton to a page of my choice.Script i am using is: <SCRIPT language=JavaScript><!-- function validate(form) {...
1
by: digituf | last post by:
can someone help me by telling me why is that whenever i click the javascript calendar, it redirect me to another page eventhough i still do not finish fill the form? here is the code: ...
2
by: lka527 | last post by:
I am trying to make a site available for someone to *upload* certain type of text file (.txt) that can be parsed by written code. the upload file is available on the main site but I need this to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.