function formvalidation(thisform)
{
with (thisform)
{
if (emptyvalidation(firstname,"Please enter your first name")==false) {firstname.focus(); return false;};
if (emptyvalidation(surname,"Please enter your surname")==false) {surname.focus(); return false;};
if (emptyvalidation(organisation,"Please enter your Company or Organisation")==false) {organisation.focus(); return false;};
if (emailvalidation(email,"Invalid email format")==false) {email.focus(); return false;};
//if (emptyvalidation(address,"Please enter your address")==false) {address.focus(); return false;};
//if (emptyvalidation(postcode,"Please enter your postcode")==false) {postcode.focus(); return false;};
if (emptyvalidation(phone,"Please enter a daytime telephone number")==false) {phone.focus(); return false;};
if (emptyvalidation(comments,"You haven't made a comment or enquiry")==false) {comments.focus(); return false;};
//if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
//if (digitvalidation(Digits,3,4,"You MUST enter 3 or 4 integer digits","I")==false) {Digits.focus(); return false;};
}
}

function valuevalidation(entered, min, max, alertbox, datatype)
{
// Value Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
}
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


function emptyvalidation(entered, alertbox)
{
// Emptyfield Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


function emailvalidation(entered, alertbox)
{
// E-mail Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}

