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

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Form Validation Problem in IE7
onsubmit doesn't work properly?

5+ Year Member

Msg#: 3432680 posted 8:21 pm on Aug 26, 2007 (gmt 0)

OK, I have this:

<script type="text/javascript">
String.prototype.trim = function(){return this.replace(/^\s+\s+$/g,'')}
var regEmail = /^[a-z0-9][a-z0-9_\.-]+@[a-z0-9_\.-]+\./i;

function validate(form)
var errMessages=[];
if (form.email.value!="")
{if (! regEmail.test( form.email.value.trim()))
errMessages.push("Please enter a valid email Address.");
var valid =!errMessages.length;

return valid;

and then

<form action="contact.php" method="post" id="cForm" onsubmit="return validate(this);" >
<label id="textfield" for="posEmail">E-mail:</label>
<input class="text" type="text" size="25" name="email" />
<input class="submit" src="images/signup.jpg" type="image" name="Submit" id="sendContactEmail" />

It works in everything but IE7. There, the form can't be submitted at all. Nothing happens when you press the submit button or press enter in the form.

Can anyone help work out what's going wrong?



WebmasterWorld Senior Member 10+ Year Member

Msg#: 3432680 posted 10:30 am on Aug 27, 2007 (gmt 0)

It works fine in my IE7.

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