
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="Please enter full 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="Please enter a valid<br/> email address";
document.getElementById("emailError").style.color="#666666";
}


// check the telephone
if(f.telephone.value.length < 1){
document.getElementById("telephoneError").innerHTML="* Mobile or Fixed line";
document.getElementById("telephoneError").style.color="red";


errors = 1;
}
else
{
document.getElementById("telephoneError").innerHTML="Please enter a telephone number";
document.getElementById("telephoneError").style.color="#666666";
}
// check the business name
if(f.businessname.value.length < 1){
document.getElementById("businessnameError").innerHTML="* Business name";
document.getElementById("businessnameError").style.color="red";


errors = 1;
}
else
{
document.getElementById("businessnameError").innerHTML="Please enter your <br/>business name";
document.getElementById("businessnameError").style.color="#666666";
}


// check the business type
if(f.businesstype.value.length < 1){
document.getElementById("businesstypeError").innerHTML="* Business type";
document.getElementById("businesstypeError").style.color="red";


errors = 1;
}
else
{
document.getElementById("businesstypeError").innerHTML="Please enter your <br/>business type";
document.getElementById("businesstypeError").style.color="#666666";
}

// check the business address
if(f.address.value.length < 1){
document.getElementById("addressError").innerHTML="* Business address";
document.getElementById("addressError").style.color="red";


errors = 1;
}
else
{
document.getElementById("addressError").innerHTML="Please enter your <br/>business address";
document.getElementById("addressError").style.color="#666666";
}

// check the county
if(f.addresscounty.value.length < 1){
document.getElementById("countyError").innerHTML="* Please enter your county";
document.getElementById("countyError").style.color="red";


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

// check the advice
if(f.advice.value.length < 1){
document.getElementById("adviceError").innerHTML="* Please describe advice needed";
document.getElementById("adviceError").style.color="red";


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


// make sure the form is not submitted if there are errors
if (errors > 0){
document.getElementById("topError").innerHTML="Some fields have been left blank. Please fill in these fields before submitting 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

}





