473,386 Members | 1,705 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,386 software developers and data experts.

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="JavaScript">

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="validate();" >
</form>

</body>

May 7 '06 #1
4 1662


goga wrote:

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


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

--

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


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

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.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="return 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
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...
7
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. ...
4
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...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
27
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...
6
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...
5
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...
3
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...
3
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.