// JavaScript Document
<!-- Begin - mandatory field validation
function checkFields() {
missinginfo = "";
if (document.ecmApplication.firstName.value == "") {
missinginfo += "\n     -  First Name";
}
if (document.ecmApplication.lastName.value == "") {
missinginfo += "\n     -  Last Name";
}
if (document.ecmApplication.age.value == "") {
missinginfo += "\n     -  Age";
}
/*if (document.ecmApplication.grade.value == "") {
missinginfo += "\n     -  Your Grade";
}if (document.ecmApplication.yourHighSchool.value == "") {
missinginfo += "\n     -  Your High School";
}*/
if (document.ecmApplication.address.value == "") {
missinginfo += "\n     -  Address";
}
if (document.ecmApplication.city.value == "") {
missinginfo += "\n     -  City";
}
if (!validatePostalZip(document.ecmApplication.postalcode.value)) {
missinginfo += "\n     -  Postal Code";
}
/*if (document.ecmApplication.postalcode.value == "") {
missinginfo += "\n     -  Postal Code";
}*/
if (!validateEmail(document.ecmApplication.email.value)) {
missinginfo += "\n     - Email Address";
}

/*if (document.ecmApplication.email.value == "") {
missinginfo += "\n     -  Email";
}*/
/*if (document.ecmApplication.areaCode.value == "") {
missinginfo += "\n     -  Your Area Code";
}
if (document.ecmApplication.phoneNum.value == "") {
missinginfo += "\n     -  Your Phone Number";
}*/
if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"Ooops, you forgot to fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease complete these fields and submit again!";
alert(missinginfo);
return false;
}
else return true;
}
//  End -->

function validateEmail ( email ) {
 emailRe = /^[a-zA-Z_0-9-'\+~]+(\.[a-zA-Z_0-9-'\+~]+)*@([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,7}$/;
 if( !emailRe.test( email ) ) {
  return false;
 }
 return true;
}

function validatePostalZip ( postalZip ) {
 postalZipRe = /^((\d{5}-\d{4})|(\d{5})|([AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvXxYy]\d[A-Za-z]\s?\d[A-Za-z]\d))$/;
 if( !postalZipRe.test( postalZip ) ) {
  return false;
 }
 return true;
}
<!-- Original:  Nannette Thacker -->
<!-- http://www.shiningstar.net -->
<!-- Begin
function checkNumeric(objName,minval, maxval,comma,period,hyphen)
{
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen)
{
// only allow 0-9 be entered, plus any values passed
// (can be in any order, and don't have to be comma, period, or hyphen)
// if all numbers allow commas, periods, hyphens or whatever,
// just hard code it here and take out the passed parameters
var checkOK = "0123456789" + comma + period + hyphen;
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";

for (i = 0;  i < checkStr.value.length;  i++)
{
ch = checkStr.value.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)
{	
alertsay = "Please enter only these values \""
alertsay = alertsay + checkOK + "\" in the \"" + checkStr.name + "\" field."
alert(alertsay);
return (false);
}

// set the minimum and maximum
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
{
alertsay = "Please enter a value greater than or "
alertsay = alertsay + "equal to \"" + minval + "\" and less than or "
alertsay = alertsay + "equal to \"" + maxval + "\" in the \"" + checkStr.name + "\" field."
alert(alertsay);
return (false);
}
}

function ValidateForm()
{
	
	if (MM_findObj("namefirst").value == "") {
		alert("You must enter a first name.");
		MM_findObj("namefirst").focus();
		return false;
	}
	if (MM_findObj("state").selectedIndex == 0) {
		alert("You must select your state.");
		MM_findObj("state").focus();
		return false;
	}  
   
   return true;
}	
//  End -->

