function Form1_Validator(theForm)
{

var alertsay = ""; 
// check if Name field is blank
if (theForm.Name.value == "")
{
alert("Please enter a value for the \"Name\" field.");
theForm.Name.focus();
return (false);
}
// check if Phone field is blank
if (theForm.Phone.value == "")
{
alert("Please enter a value for the \"Phone\" 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 \"Mobile\" field.");
theForm.Phone.focus();
return (false);
}
// check if Mobile field is blank
if (theForm.Mobile.value == "")
{
alert("Please enter a value for the \"Mobile\" field.");
theForm.Mobile.focus();
return (false);
}

// only allow numbers to be entered Mobile
var checkOK = "0123456789 ";
var checkStr = theForm.Mobile.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 \"Mobile\" field.");
theForm.Mobile.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 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 City is blank
if (theForm.Suburb.value == "")
{
alert("You must enter a City / Suburb.");
theForm.Suburb.focus();
return (false);
}
// check if no Region has been selected
if (theForm.Region.selectedIndex < 0)
{
alert("Please select one of the \"Region\" options.");
theForm.Region.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.Region.selectedIndex == 0)
{
alert("The first \"Region\" option is not a valid selection.");
theForm.Region.focus();
return (false);
}

// require at least one radio button be selected
var radioSelected = false;
for (i = 0;  i < theForm.CHECKBOX1.length;  i++)
{
if (theForm.CHECKBOX1[i].checked)
radioSelected = true;
}
if (!radioSelected)
{
alert("Please select one of the \"How did you find us?\" options.");
return (false);
}
// check if no How Deliver has been selected
if (theForm.HowDeliver.selectedIndex < 0)
{
alert("Please select one of the \"How Deliver\" options.");
theForm.HowDeliver.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.HowDeliver.selectedIndex == 0)
{
alert("The first \"How Deliver\" option is not a valid selection.");
theForm.HowDeliver.focus();
return (false);
}
// require at least one radio button be selected
var radioSelected = false;
for (i = 0;  i < theForm.CHECKBOX2.length;  i++)
{
if (theForm.CHECKBOX2[i].checked)
radioSelected = true;
}
if (!radioSelected)
{
alert("Please choose any of pieces you would like quote");
return (false);
}

// check if no Colours needed has been selected
if (theForm.woodcolors.selectedIndex < 0)
{
alert("Please select one of the \"Colours needed\" options.");
theForm.woodcolors.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.woodcolors.selectedIndex == 0)
{
alert("The first \"Colours needed\" option is not a valid selection.");
theForm.woodcolors.focus();
return (false);
}
// check to see if the width of 1st is blank
if (theForm.width1st.value == "")
{
alert("You must enter a width of 1st ");
theForm.width1st.focus();
return (false);
}

// check to see if the lenght of 1st is blank
if (theForm.length1st.value == "")
{
alert("You must enter a Length of 1st ");
theForm.length1st.focus();
return (false);
}

// check to see if the Quantity of 1st is blank
if (theForm.Quantity1st.value == "")
{
alert("You must enter a Quantity of 1st ");
theForm.Quantity1st.focus();
return (false);
}
}