


function Form1_Validator(theform)

{



var alertsay = ""; 



// check if email field is blank

if (theform.name.value == "")

{

alert("Please enter your name.");

theform.name.focus();

return (false);

}

if (theform.email.value == "")

{

alert("Please enter your email address.");

theform.email.focus();

return (false);

}



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 (EmailAt && EmailPeriod)

{

		EmailValid = true

		break;

	}

}

if (!EmailValid)

{

alert("The \"email\" field is invalid. Please re-enter.");

theform.email.focus();

return (false);

}

return (true);

}


function Form2_Validator(theform)

{



var alertsay = ""; 



// check to see if the field is blank

if (theform.fname.value == "")

{

alert("You must enter your first name.");

theform.fname.focus();

return (false);

}



if (theform.lname.value == "")

{

alert("You must enter your last name.");

theform.lname.focus();

return (false);

}



if (theform.phone.value == "")

{

alert("You must enter your phone number.");

theform.phone.focus();

return (false);

}



var checkOK = "0123456789-()";

var checkStr = theform.phone.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 numeric characters in the \"phone number\" field.");

theform.phone.focus();

return (false);

}



// check if email field is blank

if (theform.email.value == "")

{

alert("Please enter a value for the \"Email\" field.");

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 is invalid. Please re-enter.");

theform.email.focus();

return (false);

}



// check if email field is blank

if (theform.message.value == "")

{

alert("Please enter a message.");

theform.message.focus();

return (false);

}

	return (true);

}


