469,909 Members | 1,630 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

Issue with "return false;"

I have a return false as part of my if statement and my form is still submitting.

Here is the simple example. Any suggestions?
if(msg != ""){
alert(msg);
return false;
}else{
//submit the form
}
Jul 23 '05 #1
2 1214
On 26 May 2004 12:10:08 -0700, gachris wrote:
Here is the simple example.
It's probably in the bit you left out..
URL?
..Any suggestions?


Supply an URL,
get regular sleep,
be good to your mother.
(not necessarily in that order) ;-)

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #2
Lee
gachris said:

I have a return false as part of my if statement and my form is still
submitting.

Here is the simple example. Any suggestions?
if(msg != ""){
alert(msg);
return false;
}else{
//submit the form
}


Most commonly this is because your validation function is returning
false to the onsubmit handler, but the onsubmit handler function
is not returning that value to the browser. The onsubmit handler
is the value of the HTML onsubmit attribute (usually), so instead
of something like:

onsubmit="myValidationFunction(this)"

you should have something like:

onsubmit="return myValidationFunction(this)"

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by yingjian.ma1955 | last post: by
40 posts views Thread by Mark P | last post: by
5 posts views Thread by Ben | last post: by
reply views Thread by =?Utf-8?B?bXVzb3NkZXY=?= | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.