
<!--
function Form1_Validator(theForm)
{
	
// check to see if the field is blank
if (theForm.txtFirstName.value == "")
{
alert("You must enter your First Name.");
theForm.txtFirstName.focus();
return (false);
}

// require at least 2 characters be entered
if (theForm.txtFirstName.value.length < 2)
{
alert("Please enter at least 2 characters in the \"FirstName\" field.");
theForm.txtFirstName.focus();
return (false);
}

// check to see if the field is blank
if (theForm.txtSurName.value == "")
{
alert("You must enter your Surname.");
theForm.txtSurName.focus();
return (false);
}

// check to see if the field is blank
if (theForm.txtCompany.value == "")
{
alert("You must enter your Company.");
theForm.txtCompany.focus();
return (false);
}

// check to see if the field value is not 0
if (theForm.b4.value == "0")
{
alert("You must enter your Electricity cost.");
theForm.b4.focus();
return (false);
}

var checkOK = "0123456789";
var checkStr = theForm.b4.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please enter only numeric characters for Electricity cost ( commas and £ signs ) are not required.");
theForm.b4.focus();
return (false);
}


// check to see if the field value is not 0

var checkOK = "0123456789";
var checkStr = theForm.b5.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please enter only numeric characters for Gas costs ( commas and £ signs ) are not required.");
theForm.b5.focus();
return (false);
}

// check to see if the field value is not 0
if (theForm.b24.value == "0")
{
alert("You must choose one or more options to continue.");
theForm.b24.focus();
return (false);
}

// check if email field is blank
var form_email = theForm.txtEmail.value;
var invalidChars = " /:;,"
var badChar =""
if (form_email== "")
{
alert("You must enter your Email.");
 return (false);
}
for (i = 0;  i < invalidChars.length;  i++)
{
badChar=invalidChars.charAt(i);
if(form_email.indexOf(badChar,0)>-1)
{
alert("The email field is incorrect. \nPlease enter a valid email address");
theForm.txtEmail.focus();
return (false);
}
}
atPos=form_email.indexOf("@",1)
if(atPos==-1)
{
alert("Your Email is not Valid, must have an @");
theForm.txtEmail.focus();
return (false);
}
if(form_email.indexOf("@",atPos+1)>-1)
{
alert("You cannot have two @'s");
theForm.txtEmail.focus();
return (false);
}
periodPos=form_email.indexOf(".",atPos)
if(periodPos==-1)
{
alert("There must be an . in your email address");
theForm.txtEmail.focus();
return (false);
}
if(periodPos+3>form_email.length)
{
alert("There must be atleast two letters after .");
theForm.txtEmail.focus();
return (false);
}


return (true);
}
//-->

   
