/* validateCommentForm(this)


This function validates the following commonly required form fields:
  - First Name
  - Last Name
  - Email Address

This function alerts the user via a pop-up dialog containing the error message 

This script runs on the onSubmit event of the form. In order to use this function add the following to form:

	name="myForm"
	onSubmit="return validateContactFormAlert(this);" 


*/

function validateCommentFormAlert(myForm) {
  
  // check to see if firstname is null or less than one character long

  if(myForm.fname.value == null || myForm.fname.value.length == 0 || myForm.fname.value.length <=1)
    {
	myForm.fname.select();
	alert('Invalid First Name. Please re-enter.');
	return false;
    }

  // check to see if lastname is null or less than one character long

  if(myForm.lname.value == null || myForm.lname.value.length == 0 || myForm.lname.value.length <=2)
    {
	myForm.lname.select();
	alert('Invalid Last Name. Please re-enter.');
	return false;
    }

  // check to see if email has valid format
  var emailRegExp=/^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if (!emailRegExp.test(myForm.email.value))
	  {
		myForm.email.select();
		alert('Invalid Email Address');
		return false;
      }
  
  // else everything is valid so form can go on
  return true;
  
}  //end validateCommentFormAlert(myForm);