// JavaScript Document
// Written by Stephen Hepden
// 
<!--hide from old browsers 

function checkform() {
var valerror = 0;
var valcontactset = 0;
var strErrorMessage = "Please correct the following fields:\n";
var varfieldvalue = "";
// Check the length of the title field
varfieldvalue = removeWhitespace(document.feedback.title.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "Title, \n";
	}
// Check the length of the Surname field
varfieldvalue = removeWhitespace(document.feedback.surname.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "Surname, \n";
	}	
	
// Check the length of the Company field
varfieldvalue = removeWhitespace(document.feedback.company.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "Company, \n";
	}		

// Check email address for certain characters
var sentence=document.feedback.emailaddress.value;
if (sentence.indexOf("@")!=-1 && sentence.indexOf(".")!=-1 && sentence.length > 5)
	{
	//alert("Email Good")		
	}
	else
	{
	//alert("Email Bad")		
	strErrorMessage = strErrorMessage + "Invalid Email Address, \n";
	valerror = valerror + 1;
	}

// Check the length of the Telephone field
varfieldvalue = removeWhitespace(document.feedback.telephone.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "Phone Number, \n";
	}		
	
// Check the length of the Question field
varfieldvalue = removeWhitespace(document.feedback.question.value);	
if (varfieldvalue == '' )
	{
	valerror = valerror + 1;
	strErrorMessage = strErrorMessage + "Question\n";
	}			

// Now see if the error count is > 0, if so then the validation has failed, abort form submit and prompt user	
if (valerror>0)
	{
	//alert (strErrorMessage);
	return strErrorMessage;	
	}
	else
	{
	//alert ('Passed');	
//	alert('Thank you, your details have now been saved sucessfully');
	return true;	
	}

}

function removeWhitespace(str){
  return str.replace(/^\s+/,"").replace(/\s+$/,"").replace(/\s+/g," ");
}

function printpage() 
{window.print();}
// -->