473,407 Members | 2,312 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,407 software developers and data experts.

Why does my form keep submiting when I don't want it too?

Ajm113
161 100+
Ok for some reason after the update of Firefox it seems that my form keeps getting submitted when the user made a error on the form. I just want the page to reload so the user may try again. Because I have it so the submit button is a hit once only.

Here is the code:
Expand|Select|Wrap|Line Numbers
  1.     <SCRIPT LANGUAGE="JavaScript">
  2.  
  3. function validateForm(form)
  4. {
  5.  
  6.     if (form.username.value == "")
  7.     {
  8.     alert('You did not enter a username!');
  9.     form.username.focuse();
  10.     location.reload();
  11.     return false;
  12.     }else{
  13.  
  14.  
  15.     if (form.security_code.value != "DOOM34K10")
  16.     {
  17.     alert('You did not enter the correct security code!');
  18.     form.security_code.focuse();
  19.     location.reload();
  20.     return false;
  21.     }else{
  22.  
  23.     if (form.email.value == "") {
  24.     alert('We need to contact you through email!');
  25.     form.email.focus();
  26.     location.reload();
  27.     return false;
  28.     }else{
  29.  
  30.     if (form.email.value == "someone@site.com") {
  31.     alert('I am sure as heck that your email is not what you entered!');
  32.     form.email.focus();
  33.     location.reload();
  34.     return false;
  35.     }else{ 
  36.  
  37.     if (form.password1.value == "")
  38.     {
  39.     alert('You did not enter a password!');
  40.     form.password1.focuse();
  41.     location.reload();
  42.     return false;
  43.     }else{
  44.  
  45.     if (form.password2.value == "")
  46.     {
  47.     alert('You did not enter the second password!');
  48.     form.password2.focuse();
  49.     location.reload();
  50.     return false;
  51.     }else{
  52.  
  53.  
  54.     if (form.password1.value != form.password2.value)
  55.     {
  56.     alert('The passwords you entered are diffrent!');
  57.     form.password1.focuse();
  58.     form.password2.focuse();
  59.     location.reload();
  60.     return false;
  61.     }else{
  62.  
  63.  
  64. document.forms[0].submit();
  65. return true;
  66.         }
  67.             }
  68.         }
  69.     }
  70.         }
  71.     }
  72.             }
  73.         }
  74.  
  75.     </SCRIPT>
Aug 26 '07 #1
3 1394
acoder
16,027 Expert Mod 8TB
There's no point of the returns if you're going to navigate away from the page.

Your problem might be focuse() which should be focus().
Aug 27 '07 #2
Ajm113
161 100+
Thanks, it works fine now!
Aug 28 '07 #3
acoder
16,027 Expert Mod 8TB
Glad you got it working. Post again if you hit any more problems.
Aug 28 '07 #4

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

Similar topics

2
by: Bruno Alexandre | last post by:
Hi guys, If I want to block a user to change a form after submiting, I add a function that will disable the submit button, but when I'm getting the form collection (using post or get...
3
by: David Gonneau | last post by:
I'm getting an incredible behaviour of internet explorer. I have a generated html page with one form and many input of checkbox type. Those checkbox are grouped in 4 lists and each list of...
11
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that...
3
by: goodmorningegg | last post by:
I've created a website using PHP that makes the page look like forms are being used. My problem is that when I submit a form it opens up to a brand new blank page saying "thanks for submitting the...
14
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
0
by: pankaj1703 | last post by:
i am create one enquiry form after submiting the information fillup by the end user then it get thanks message. if it press back button it go to the enquiry form fill by him that i want to prevent...
19
by: Angus | last post by:
I have a socket class CTestClientSocket which I am using to simulate load testing. I create multiple instances of the client like this: for (int i = 0; i < 5; i++) { CTestClientSocket* pTemp...
6
by: bizt | last post by:
Hi, First let me point out I have googled this and also must have done this operation a dozen times (altho a few years ago) but for some reason I cant get a form to submit using javascript .....
5
by: rodrigo21 | last post by:
I have a form that submits the form values to the same page (of the form). The database is feed from the same page that have the form in it. So the action attribute would look like this <form...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.