
function emptyvalidation(entered)
{
with (entered)
{
if (value==null || value=="")
{alert("Please ensure all boxes are correctly completed"); return false;}
else {return true;}
}
} 

function telephonevalidation(entered)
{
with(entered)
{
var stripped = value.replace(/[^\d]+/g, "");
// strip out unacceptable non-numeric chars
if (value==null || value=="")
{
	alert("Please enter a telephone number");
	return false;
}
else 
{
	if (isNaN(parseInt(stripped)))  
	{
		alert("Please enter a valid 10-12 digit telephone number");
		return false;
	}
	else 
	{
		if (stripped.length < 10 || stripped.length > 12) 
		// test stripped number length against acceptable range
		{
			alert("Please enter a valid 10-12 digit telephone number");
			return false;
		}
		else 
		{
			return true;
		}
	}
}
}
}

function emailvalidation(entered)
{
with(entered)
{
// var emailFilter=/^.+@.+\..{2,3}$/;
//alternate email filter (more simple)
var emailFilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!(emailFilter.test(value))) 
{
	alert("Please enter a valid email address");
	return false;
}
else
{
	return true;
}
}
}


function formvalidation(thisform)
{
with (thisform)
{
if (emptyvalidation(name)==false) {name.focus(); return false;};
if (emailvalidation(email)==false) {email.focus(); return false;};
if (emptyvalidation(phone)==false) {phone.focus(); return false;};
if (emptyvalidation(subject)==false) {subject.focus(); return false;};
if (emptyvalidation(message)==false) {message.focus(); return false;};
}
} 
