In your onSubmit
you are calling return ValidateForm()
when you should be doing return validateForm()
with a lowercase "v". There are some others:
{function validateForm()
should be function validateForm()
You never close the functions opening brace after the if statement.
<form name="contact" action="mailer.php" onsubmit="return validateForm()" method="post">
and then:
function validateForm() {
var x = document.forms["contact"]["name"].value;
if (x == null || x == "") {
alert("Name field must be filled out");
return false;
}
var x = document.forms["contact"]["email"].value;
var atpos = x.indexOf("@");
var dotpos = x.lastIndexOf(".");
if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= x.length) {
alert("Not a valid e-mail address");
return false;
}
var x = document.forms["contact"]["tel"].value;
if (y == null || y == "") {
alert("Phone number must be provided");
return false;
}
var x = document.forms["contact"]["message"].value;
if (x == null || x == "") {
alert("You have not entered a message");
return false;
}
}