Hi there,

I am trying to get validation on a form so I receive a email from php script. The onSubmit="return validate(this)" seems to be causing the php page to die so the email isn't sent! Please can anyone help! The Code and PHP is below.


Code:
<script type="text/javascript">
		<!--
		function validateEmail()
		{
 
 			var emailID = document.contact.Email.value;
  			atpos = emailID.indexOf("@");
   			dotpos = emailID.lastIndexOf(".");
   			if (atpos < 1 || ( dotpos - atpos < 2 )) 
   			{
       				return false;
 	  		}
  			return true;
		}

		function validate()
		{
			if( document.contact.name.value == "" )
   			{
     				alert( "Please provide your name!" );
     				document.contact.name.focus() ;
     				return false;
   			}
			var ret = validateEmail();
   			if( ret == false )
   			{
   				alert( "Please provide a correct Email!" );
    				document.contact.Email.focus() ;
     				return false;
   			}
 			if( document.contact.message.value == "" )
   			{
     				alert( "Please provide your Enquiry!" );
     				document.contact.message.focus() ;
     				return false;
   			}
   			return true;
		}
		//-->
		</script>
Code:
				<form name="contact" action="contact.php" onSubmit="return validate(this)" " method="POST">
 					<tr>
  						<td align="right">Name</td>
 						<td><input type="text" name="name" /></td>
 					</tr>
 					<tr>
   						<td align="right">Email</td>
   						<td><input type="text" name="Email" /></td>
					</tr>
					<tr>
   						<td align="right">Message</td>
  						<td><input type="text" name="message" /></td>
 					</tr>
   						<td><input type="submit" name="submit" value="Submit your Enquiry" /></td>
 					</tr>
 				</form>

PHP Code:
<?php
$name 
$_POST['name'];
$Email $_POST['Email'];
$message $_POST['message'];
$formcontent=" From: $name \n Email address: $Email \n Enquiry: $message";
$recipient "jacob50.jba@googlemail.com";
$subject "TADS Website Enquiry";
$mailheader "From: $Email \r\n";
mail($recipient$subject$formcontent$mailheader) or die("Error!");
header('Location: http://tadsuk.com/contact.html');
?>