function Form1_Validator(theForm)
{

var alertsay = ""; 

// require at least one radio button be selected
var radioSelected = false;
for (i = 0;  i < theForm.poolrange.length;  i++)
{
if (theForm.poolrange[i].checked)
radioSelected = true;
}
if (!radioSelected)
{
alert("Please select the \"range you would like us to quote you on?\" options.");
return (false);
}

// check if Customer Name field is blank
if (theForm.name.value == "")
{
alert("Please enter a value for the \"Name\" field.");
theForm.name.focus();
return (false);
}


// check to see if the Address is blank
if (theForm.address.value == "")
{
alert("You must enter a Address.");
theForm.address.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.address.value.length < 3)
{
alert("Please enter at least 3 characters in the \"Address\" field.");
theForm.address.focus();
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
// this can be altered for any "checkOK" string you desire
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ";
var checkStr = theForm.address.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 letter and numeric characters in the \"Address\" field.");
theForm.address.focus();
return (false);
}

// check to see if the Suburb is blank
if (theForm.suburb.value == "")
{
alert("You must enter a Suburb.");
theForm.suburb.focus();
return (false);
}

// check if Post Code  field is blank
if (theForm.postcode.value == "")
{
alert("Please enter a value for the \"Post Code\" field.");
theForm.postcode.focus();
return (false);
}

// only allow numbers to be entered Postcode
var checkOK = "0123456789 ";
var checkStr = theForm.postcode.value;
var allValid = true;
var allNum = "";
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 (ch != ",")
allNum += ch;
}
if (!allValid)
{
alert("Please enter only digit characters in the \"Post Code\" field.");
theForm.postcode.focus();
return (false);
}


// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.email.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkEmail.length;  j++)
{
if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;
if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
		EmailValid = true
		break;
	}
}
if (!EmailValid)
{
alert("The \"email\" field must contain an \"@\" and a \".\".");
theForm.email.focus();
return (false);
}

if (theForm.email.value.length < 5)
{
alert("Please enter a value for the \"Email\" field.");
theForm.email.focus();
return (false);
}

// check if no Feedback has been selected
if (theForm.feedback.selectedIndex < 0)
{
alert("Please select one of the \"How did you find us\" options.");
theForm.feedback.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.feedback.selectedIndex == 0)
{
alert("The first \"How did you find us\" option is not a valid selection.");
theForm.feedback.focus();
return (false);
}

// check if Home Number field is blank
if (theForm.phone.value == "")
{
alert("Please enter a value for the \"Home Number\" field.");
theForm.phone.focus();
return (false);
}

// only allow numbers to be entered Phone
var checkOK = "0123456789 ";
var checkStr = theForm.phone.value;
var allValid = true;
var allNum = "";
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 (ch != ",")
allNum += ch;
}
if (!allValid)
{
alert("Please enter only digit characters in the \"Home Number\" field.");
theForm.phone.focus();
return (false);
}

}
