homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Submit Onclick event does not work on IE

5+ Year Member

Msg#: 3763934 posted 3:43 am on Oct 12, 2008 (gmt 0)

I have a form:

<form name="bookp" id="bookp" method="POST" action="page.php" onSubmit="return ValidateE()">

And the submit button

<input name="submit" id="submit" value="Submit" onClick="validateFor = 0;">

and the script,

function ValidateE() {
if (validateFor == 0)
if (IsEmpty(document.getElementById("bookp").corpcontact)) {
alert("Please Enter Full Name");
return false;
return true;

All this works perfectly in Firefox/safari but not on IE.. any help ?



WebmasterWorld Administrator httpwebwitch us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 3763934 posted 4:51 am on Oct 12, 2008 (gmt 0)

welcome to WebmasterWorld, cybertai!

you've got two things happening triggered by the same action, which are dependent on happening in a particular order. Not ideal.

put an alert() into the onclick and consubmit events. see which IE executes first - the "click", or the "submit". maybe the onsubmit is happening before the onclick? test it in FF, OP, SF, IE, GC, etc. If the submit is happening before the click, "validateFor" will be undefined when validateE() is triggered.

what is validateFor for?
there's got to be another way to accomplish the same thing

you may have discovered one of the plethora of subtle nuances wherein browsers behave inconsistently. it is helpful to us all if you could diagnose it definitively and publish your findings


5+ Year Member

Msg#: 3763934 posted 11:57 am on Oct 12, 2008 (gmt 0)

If you have an onSubmit method in your FORM tag doesn't it need to perform the form["bookp"].submit() ?

Is IE case sensitive about onSubmit ? (just looking at some of my code I am referencing it as "onsubmit")

We just put the JavaScript validation routine in the OnClick for the SUBMIT button - something like:

<input name="submit" id="submit" value="Submit" onClick="return MySubmit();">

function MySubmit()
var MyForm = form["bookp"];
if (typeof MyForm === "undefined")
alert("MyForm Object is undefined");
} else
// Perform validation
if (MyForm.onsubmit())
return false;

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved