﻿// FrontPage generated form field validation - included e-mail check

function FrontPage_Form1_Validator(theForm)
{
  if (theForm.txtName.value == "")  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.txtName.focus();
    return (false);  }

  if (theForm.txtName.value.length < 2)  {
    alert("Please enter at least 2 characters in the \"Name\" field.");
    theForm.txtName.focus();
    return (false);  }

  if (theForm.txtName.value.length > 50)  {
    alert("Please enter at most 50 characters in the \"Name\" field.");
    theForm.txtName.focus();
    return (false);  }

  if (theForm.txtCompany.value == "")  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.txtCompany.focus();
    return (false);  }

  if (theForm.txtCompany.value.length < 2)  {
    alert("Please enter at least 2 characters in the \"Company\" field.");
    theForm.txtCompany.focus();
    return (false);  }

  if (theForm.txtCompany.value.length > 50)  {
    alert("Please enter at most 50 characters in the \"Company\" field.");
    theForm.txtCompany.focus();
    return (false);  }
  
  if (theForm.txtPhone.value.search(/\d{3}\-\d{3}\-\d{4}/)==-1)  {
    alert("The phone number you entered is not valid.\r\nPlease enter a phone number with the format xxx-xxx-xxxx.");
    theForm.txtPhone.focus();
    return (false);  }
  
  if (theForm.txtEmail.value == "")  {
    alert("Please enter a value for the \"eMail\" field.");
    theForm.txtEmail.focus();
    return (false);  }

  if (theForm.txtEmail.value.length < 2)  {
    alert("Please enter at least 2 characters in the \"eMail\" field.");
    theForm.txtEmail.focus();
    return (false);  }

  if (theForm.txtEmail.value.length > 50)  {
    alert("Please enter at most 50 characters in the \"eMail\" field.");
    theForm.txtEmail.focus();
    return (false);  }
  
  if (!validateEmail(theForm.txtEmail.value,0,1))  {
	/* alert("The eMail address you entered is not valid; please correct any errors present."); */
    theForm.txtEmail.focus();
	return (false);   }

  if (theForm.txtComments.value == "")  {
    alert("Please enter a value for the \"Comments\" field.");
    theForm.txtComments.focus();
    return (false);  }

  if (theForm.txtComments.value.length < 2)  {
    alert("Please enter at least 2 characters in the \"Comments\" field.");
    theForm.txtComments.focus();
    return (false);  }

  if (theForm.txtComments.value.length > 1000)  {
    alert("Please enter at most 1000 characters in the \"Comments\" field.");
    theForm.txtComments.focus();
    return (false);  }
  return (true);
}
