homepage Welcome to WebmasterWorld Guest from 54.161.214.221
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
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
cybertai




msg:3763936
 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");
document.getElementById("bookp").corpcontact.focus();
return false;
}
return true;
}
}

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

 

httpwebwitch




msg:3763956
 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

Krispy2




msg:3764047
 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())
{
MyForm.submit();
}
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