function isvalid()
{
// start email check
// check email has exactly one at symbol
temail = document.forms[0].email_address.value;
//is anything entered?
contactinfo = 0;
if (temail != "") {
counter = 0;
//contactinfo is to check that at least one of phone or email has been entered
for (i = 0; i < temail.length; i++) {
	if(temail.substr(i,1) == '@') {
		counter++;
	}
}

if(counter != 1) {
	alert('Please check the email address you have entered, as it appears to be invalid');
	return false;
	}
else {
	contactinfo++;
}
//trim
temail.replace(/^[\s]+$[\s]+/,"");
//are any of the following characters in the email address space:;, ?
if (temail.search(/[\s:;,]/) > -1) {
	alert('Please check the email address you have entered, as it appears to be invalid');
	return false;
}
}
//end email check

//is there something in the phone field?
tphone = document.forms[0].phone.value;
if (tphone != "") {
	contactinfo++;
}
if (contactinfo < 1) {
	alert('Please enter an email address or phone number so we can reply');
	return false;
}
// check message <= 2048 characters
tmessage = document.forms[0].message.value;
if(tmessage.length > 2048) {
	alert('Sorry, but the message length is limited to 2048 characters. Please shorten the message or alternatively use your normal email client to send it');
	return false;
}
return true;
}
