function Form1_Validator(theForm)
{

var alertsay = ""; // define for long lines
// alertsay is not necessary for your code,
// but I need to break my lines in multiple lines
// so the code won't extend off the edge of the page

// check to see if the user field is blank
if (theForm.user.value == "")
{
alert("You must enter an Username.");
theForm.user.focus();
return (false);
}


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


// require at least 5 characters in the password field
//if (theForm.pass.value.length == "")
//{
//alert("Please enter at least 5 characters in the \"Password\" field.");
//theForm.pass.focus();
//return (false);
//}

// check if both password fields are the same
//if (theForm.Password.value != theForm.Password2.value)
//{
//	alert("The two passwords are not the same.");
//	theForm.Password2.focus();
//	return (false);
//}


// check if email field is blank
if (theForm.email.value == "")
{
alert("Please enter an Email Address.");
theForm.email.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);
}


// check to see if the first name field is blank
if (theForm.fname.value == "")
{
alert("You must enter a First Name.");
theForm.fname.focus();
return (false);
}


// check to see if the last name field is blank
if (theForm.lname.value == "")
{
alert("You must enter a Last Name.");
theForm.lname.focus();
return (false);
}


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


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


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


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

// check if the first drop down is selected, if so, invalid selection
if (theForm.state.selectedIndex == 0)
{
alert("Please select a State.");
theForm.state.focus();
return (false);
}


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

// check if the first drop down is selected, if so, invalid selection
if (theForm.country.selectedIndex == 0)
{
alert("Please select a Country.");
theForm.country.focus();
return (false);
}



// check to see if the zip field is blank
if (theForm.phone.value == "")
{
alert("You must enter a Primary Phone Number.");
theForm.phone.focus();
return (false);
}

// require at least one radio button be selected
var radioSelected = false;
for (i = 0;  i < theForm.category.length;  i++)
{
if (theForm.category[i].checked)
radioSelected = true;
}
if (!radioSelected)
{
alert("Please Select a Brand Marketer or Retailer.");
return (false);
}



/*

// require at least 3 characters be entered
//if (theForm.Alias.value.length < 3)
//{
//alert("Please enter at least 3 characters in the \"Alias\" field.");
//theForm.Alias.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.Alias.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 \"Alias\" field.");
//theForm.Alias.focus();
//return (false);
//}


// allow only 150 characters maximum in the comment field
if (theForm.comment.value.length > 150)
{
alert("Please enter at most 150 characters in the comment field.");
theForm.comment.focus();
return (false);
}

// check if no drop down has been selected
if (theForm.sex.selectedIndex < 0)
{
alert("Please select one of the \"Gender\" options.");
theForm.sex.focus();
return (false);
}

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

// check if no drop down or first drop down is selected, if so, invalid selection
if (theForm.date_month.selectedIndex <= 0)
{
alert("Please select a month.");
theForm.date_month.focus();
return (false);
}

// check if no drop down or first drop down is selected, if so, invalid selection
if (theForm.date_day.selectedIndex <= 0)
{
alert("Please select a day.");
theForm.date_day.focus();
return (false);
}

// check if no drop down or first drop down is selected, if so, invalid selection
if (theForm.date_year.selectedIndex <= 0)
{
alert("Please select a year.");
theForm.date_year.focus();
return (false);
}

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

// only allow numbers to be entered
var checkOK = "0123456789";
var checkStr = theForm.numbers.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 \"numbers\" field.");
theForm.numbers.focus();
return (false);
}

// check if no drop down or first drop down is selected, if so, invalid selection
if (theForm.rangefrom.selectedIndex <= 0)
{
alert("Please select a valid number in the range \"From\" field.");
theForm.rangefrom.focus();
return (false);
}

// check if no drop down or first drop down is selected, if so, invalid selection
if (theForm.rangeto.selectedIndex <= 0)
{
alert("Please select a valid number in the range \"To\" field.");
theForm.rangeto.focus();
return (false);
}

// require that the To Field be greater than or equal to the From Field
var chkVal = theForm.rangeto.value;
var chkVal2 = theForm.rangefrom.value;
if (chkVal != "" && !(chkVal >= chkVal2))
{
alert("The \"To\" value must be greater than or equal to (>=) the \"From\" value.");
theForm.rangeto.focus();
return (false);
}

// check if more than 5 options are selected
// check if less than 1 options are selected
var numSelected = 0;
var i;
for (i = 0;  i < theForm.province.length;  i++)
{
if (theForm.province.options[i].selected)
numSelected++;
}
if (numSelected > 5)
{
alert("Please select at most 5 of the \"province\" options.");
theForm.province.focus();
return (false);
}
if (numSelected < 1)
{
alert("Please select at least 1 of the \"province\" options.");
theForm.province.focus();
return (false);
}

// require a value be entered in the field
if (theForm.NumberText.value == "")
{
alert("Please enter a value for the \"NumberText\" field.");
theForm.NumberText.focus();
return (false);
}

// require that at least one character be entered
if (theForm.NumberText.value.length < 1)
{
alert("Please enter at least 1 characters in the \"NumberText\" field.");
theForm.NumberText.focus();
return (false);
}

// don't allow more than 5 characters be entered
if (theForm.NumberText.value.length > 5)
{
	 alertsay = "Please enter at most 5 characters in "
	 alertsay = alertsay + "the \"NumberText\" field, including comma."
alert(alertsay);
theForm.NumberText.focus();
return (false);
}

// only allow 0-9, hyphen and comma be entered
var checkOK = "0123456789-,";
var checkStr = theForm.NumberText.value;
var allValid = true;
var decPoints = 0;
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 \"NumberText\" field.");
theForm.NumberText.focus();
return (false);
}

// require a minimum of 9 and a maximum of 5000
// allow 5,000 (with comma)
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= "9" && prsVal <= "5000"))
{
	alertsay = "Please enter a value greater than or "
	alertsay = alertsay + "equal to \"9\" and less than or "
	alertsay = alertsay + "equal to \"5000\" in the \"NumberText\" field."
alert(alertsay);
theForm.NumberText.focus();
return (false);
}

// alert if the box is NOT checked
if (!theForm.checkbox1.checked)
{
alertsay = "Just reminding you that if you wish "
alertsay = alertsay + "to have our Super Duper option, "
alertsay = alertsay + "you must check the box!"
alert(alertsay);
}

// require that at least one checkbox be checked
var checkSelected = false;
for (i = 0;  i < theForm.checkbox2.length;  i++)
{
if (theForm.checkbox2[i].checked)
checkSelected = true;
}
if (!checkSelected)
{
alert("Please select at least one of the \"Test Checkbox\" options.");
return (false);
}

// only allow up to 2 checkboxes be checked
var checkCounter = 0;
for (i = 0;  i < theForm.checkbox2.length;  i++)
{
if (theForm.checkbox2[i].checked)
checkCounter = checkCounter + 1;
}
if (checkCounter > 2)
{
alert("Please select only one or two of the \"Test Checkbox\" options.");
return (false);
}
*/
// because this is a sample page, don't allow to exit to the post action
// comes in handy when you are testing the form validations and don't
// wish to exit the page
alertsay = "All Validations have succeeded. "
//alertsay = alertsay + "This is just a test page. There is no submission page."
alert(alertsay);
return (true);
//replace the above with return(true); if you have a valid form to submit to
}
