473,809 Members | 2,791 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript validation works in IE but not Firefox

Hi there,

The following simple validation code works in internet explorer but
doesn't in firefox.
Specifically, in firefox shows the alert message and then loads the
action page anyway.

Any help appreciated!!

<head>
<title>test</title>

<SCRIPT type="text/javascript" LANGUAGE="JavaS cript">

function validate()
{
alert('hello');
return false;
}

</SCRIPT>

</head>
<body>

<form method="post" name="signup" ID="myform"
action="http://www.google.com" >
<input type="submit" name="action" ID="myinput" value="submit"
onMouseDown="va lidate();" >
</form>

</body>

May 7 '06 #1
4 1684


goga wrote:

<input type="submit" name="action" ID="myinput" value="submit"
onMouseDown="va lidate();" >


Use
<input type="submit"
onclick="return validate();"

--

Martin Honnen
http://JavaScript.FAQTs.com/
May 7 '06 #2
Martin Honnen <ma*******@yaho o.de> writes:
Use
<input type="submit"
onclick="return validate();"


or better yet (since it works with keyboard submission too):
<form action="..." onsubmit="retur n validate();">

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
May 7 '06 #3
Thanks guys,

the solutions worked fine, the 'return validate()' was causing me
troubles!!

Cheers

May 7 '06 #4
ASM
goga a écrit :
Hi there,

The following simple validation code works in internet explorer but
doesn't in firefox.
Specifically, in firefox shows the alert message and then loads the
action page anyway.


Absolutly not !
That works whith my Fx (and it is very curious)

The best way would be :

<form method="post" name="signup" ID="myform"
action="http://www.google.com"
onsubmit="retur n validate();">

<input type="submit" name="action" ID="myinput" value="submit">

</form>

--
Stephane Moriaux et son [moins] vieux Mac
May 7 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3697
by: Dave Blair | last post by:
Hi, I have a problem with our intranet, we are planning to install Firefox instead of Internet Explorer onto some new PCs. However, we can't get the following JavaScript to work in Firefox and similar code is used in lots of the intranet stuff. The code should bring up a message box with a warning and not allow the user to continue unless they have filled in the entry in an html form (the form is called 'myauthor').
7
2054
by: Ryan Ternier | last post by:
We're running a site that has required field validation on the login page. It works fine on our development / test machines. However, when I upload this site to our live server i get this error. In IE, the validation works, but no form ever gets submited. It doesn't even process the click event of the button. In mozilla, it works 100% (this is weird because it's usually the oposite). Any thoughts?
4
1774
by: Andre | last post by:
Hi, I have read at many place that .Net 2.0 was suppose to support client-side validation in non-IE Browser. But i've try a very simple validation, and firefox is unable to run it, it works only in IE. Do i have to make something special to make it work or the problem is still present in 2.0 ? Thanks you
8
3681
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
27
4767
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it appears that the data goes straight to the processing page, rather than the javascript seeing if data is missing and popping up an alert. I thought it may be because much of the form is populated with data from the db (lists, etc.), but when I leave...
6
1903
by: davidiwharper | last post by:
Hi there. I'm putting together a page to collect some information from our website users and send the administrator an email. To this end I have some Javascript form validation in an external file, activation.js. I have put a script tag in the header, and everything works fine in Internet Explorer 7 and Opera 9. However, the script is not being called in Firefox 2. I can tell that the script is not being called because I put a...
5
19081
by: cbs7 | last post by:
Hi all I'm a complete newbie to web development and Javascript especially. I've been creating a form for a webpage and have used a validation script gen_validatorv2.js which I downloaded from the zip file referenced on http://www.javascript-coder.com/html-form/javascript-form-validation.phtml I managed to get everything working and was testing through Firefox that alerts were generated. However at the very end I thought I'd better check...
3
1894
by: goldenv | last post by:
Hi all, I have worked an open source javascript + html page that has the potential to replace your existing browser home page. If you are interested in trying it out, or learning more about it, it is freely available at http://code.google.com/p/tphp/ I would love to hear from you if you have any comments. Thanks, Vishal
3
5562
by: PrabodhanP | last post by:
I hv following javascript form validation code works in IE but not in Mozilla-Firefox ...please suggest <script type="text/javascript"> function IsNumeric(strString) // check for valid numeric strings { var strValidChars = "0123456789.-"; var strChar; var blnResult = true;
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10378
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9198
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7653
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3013
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.