Welcome to WebmasterWorld Guest from 54.147.134.218

Forum Moderators: open

Message Too Old, No Replies

Form Validation Problem in IE7

onsubmit doesn't work properly?

     
8:21 pm on Aug 26, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 2, 2006
posts:53
votes: 0


OK, I have this:

<script type="text/javascript">
//<![CDATA[
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;

if(!valid)
alert(errMessages.join("\n"));
return valid;
}
//]]>
</script>

and then

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

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?

10:30 am on Aug 27, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 22, 2002
posts:1749
votes: 0


It works fine in my IE7.