View Full Version : return false and formmail problem

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">
<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;

<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])+/;

return true
} else {

alert("Please enter a valid e-mail address");
return false



<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)">
<td><input type="hidden" name="recipient" value="beverleyviljoen02@yahoo.com"></td>
<input type="hidden" name="redirect" VALUE="http://www.theateradvisor.com/thanks.html"> </td>

<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" />


Here's the website

Can you help?

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

<form name="newsletter" id="newsletter" action="formmail.php" method="post"

To this:

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