...

View Full Version : return false and formmail problem



beverleyviljoen
03-16-2009, 04:00 AM
Hi Guys...

I'm trying to write a form, and wrote a function to validate the email address. It recoginizes if the email address is incorrect, but yet it still tries to send the form... How can I fix it?

Here's the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="keyword" content="reviews, theater advice, theatre advice, shows, plays, broadway, musicals, theatre," />
<meta name="description" content="Theater Networking site to spread people's opinions and reviews." />
<title>Theater Advisor :: Bringing the people's reviews to you. </title>
<style type="text/css">
body {text-align: center;}

#form {text-align: center;
font-family: Helvetica, Arial, sans-serif;
}

p {text-align: center;
font-family:Helvetica, Arial, sans-serif;
margin-bottom: 50px;}

#logo {margin-top: 150px;
margin-bottom: 0px;}
#font {font-size: 36px;

}
</style>
<script language="javascript" type="text/javascript">
<!--
function isEmpty(str) {
var empty = (str == null || str == "") ? true : false
return empty
}



function validEmail(email) {

var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
if(pattern.test(email))
{

return true
} else {

alert("Please enter a valid e-mail address");
document.newsletter.email.focus();
return false
}
}

//-->
</script>

</head>

<body>
<p id="logo"><img src="images/theateradvisorlogo.jpg" height="199" width="414" alt="Theater Advisor Logo" /></p>
<p><span style="color:#f6aa19;">Real People.</span> <span style="color:#a41f20;">Honest Opinions.</span></p>
<p id="font">Coming Soon!</p>

<p>Send us your e-mail and we'll let you know when to check back!</p>

<div id="form">
<form name="newsletter" id="newsletter" action="formmail.php" method="post" onSubmit="validEmail(document.newsletter.email.value)">
<table>
<tr>
<td><input type="hidden" name="recipient" value="beverleyviljoen02@yahoo.com"></td>
<td>
<input type="hidden" name="redirect" VALUE="http://www.theateradvisor.com/thanks.html"> </td>
</tr>

<tr>
<td>Find out when we launch!</td>
<td><input type="text" name="email" id="email" size="50" onFocus="if(this.value == 'Enter your email and press submit.') { this.value = ''; }" value="Enter your email and press submit." /></td>

<td valign="top" colspan="2" align="center">
<input type="submit" />
</td>
</tr>
</table>
</form>
</div>

</body>
</html>



Here's the website
http://www.itsjustmelive.com/Theater%20Advisor/

Can you help?
Thanks

jmrker
03-16-2009, 05:09 AM
Try changing this:


<form name="newsletter" id="newsletter" action="formmail.php" method="post"
onSubmit="validEmail(document.newsletter.email.value)">


To this:


<form name="newsletter" id="newsletter" action="formmail.php" method="post"
onsubmit="return validEmail(document.newsletter.email.value)">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum