
function check_form(f) { // f is the form (passed using the this keyword)
if(f.Name.value.length < 1){
document.getElementById("nameError").innerHTML="* Add your name";
document.getElementById("nameError").style.color="red";

errors = 1;
}
else if (!check_name(f.Name.value))
{
document.getElementById("nameError").innerHTML="* Name contains invalid characters";
document.getElementById("nameError").style.color="red";
errors = 1;
}
else
{
document.getElementById("nameError").innerHTML="Add your name";
document.getElementById("nameError").style.color="#666666";
}

// check the first email address
if(!check_email(f.Email.value)){
document.getElementById("emailError").innerHTML="* Invalid email address";
document.getElementById("emailError").style.color="red";


errors = 1;
}
else
{
document.getElementById("emailError").innerHTML="Add a valid address";
document.getElementById("emailError").style.color="#666666";
}

// check the comment
if(f.comments.value.length < 1){
document.getElementById("commentsError").innerHTML="* Please enter a comment";
document.getElementById("commentsError").style.color="red";


errors = 1;
}
else
{
document.getElementById("commentsError").innerHTML="";
}



// make sure the form is not submitted if there are errors
if (errors > 0){
document.getElementById("topError").innerHTML="Please fill in all required fields and resubmit the form";
document.getElementById("topError").style.color="red";
document.getElementById("recaptchaError").style.color="red";
errors = 0;
return false;
}



// make sure the form is not submitted
}





