<!--
function FrontPage_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 field is blank
if (theForm.FromName.value == "")
{
alert("Please enter your name.");
theForm.FromName.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.FromName.value.length < 3)
{
alert("Please enter at least 3 characters in the \"Name\" field.");
theForm.FromName.focus();
return (false);
}

// check if email field is blank
if (theForm.From.value == "")
{
alert("Please enter a value for the \"Email\" field.");
theForm.From.focus();
return (false);
}


// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.From.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.From.focus();
return (false);
}


// check if no drop down or first drop down is selected, if so, invalid selection
if (theForm.employment_status.selectedIndex <= 0)
{
alert("The first \"Employment Status\" option is not a valid selection.");
theForm.employment_status.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.departments.length;  i++)
{
if (theForm.departments.options[i].selected)
numSelected++;
}
if (numSelected > 5)
{
alert("Please select at most 5 of the \"department\" options.");
theForm.departments.focus();
return (false);
}
if (numSelected < 1)
{
alert("Please select at least 1 of the \"departments\" options.");
theForm.departments.focus();
return (false);
}

// require that at least one checkbox be checked
var checkSelected = false;
for (i = 0;  i < theForm.job.length;  i++)
{
if (theForm.job[i].checked)
checkSelected = true;
}
if (!checkSelected)
{
alert("Please select at least one job category options (classified, faculty, professional, graduate assistant).");
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
return (true);
// replace the above with return(true); if you have a valid form to submit to
}
//-->