LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[Webdev] Javascript onsubmit() driving me bonkers !

[Webdev] Javascript onsubmit() driving me bonkers !

Niall O Broin niall at magicgoeshere.com
Sun Sep 24 14:20:10 IST 2000


I've just wasted more than an hour trying to make an onsubmit handler work
properly. I could not stop the form submit from happening, despite my best
efforts. If the onsubmit handler returns false, the form should not be
submitted. It transpires that this is only correct for certain vales of
false ! For example:

Handler

onsubmit="return false"

Result

Form will not be submitted, as expected.

Handler

onsubmit="var do_sub=false; return do_sub"

Result

Form will not be submitted, as expected.

Handler

onsubmit="return form_check()"

where form_check is some function which is doing whatever checking we want.

Result

Form will always be submitted, no matter what form_check() returns.

Handler

onsubmit="var do_sub=form_check(); return do_sub"

Result

Form will always be submitted, no matter what form_check() returns.


This is all with Communicator 4.72[en] under Linux - didn't check with other
browsers - if the bug is there, I have to work around it.

The eventual solution was

Handler
 
onsubmit="if (form_check()) { return true } else { return false }"
 
Result
 
Form will be submitted or not, depending on what form_check() returns -
which is exactly what I want. Note that I did verify what form_check() was
returning by appropriate Alerts. 

Is this weird or what ? Who can I sue for my hour back :-)

Regards,


Niall  O Broin




More information about the Webdev mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell