473,391 Members | 1,496 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,391 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 1392
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.