// JavaScript Document

function FrontPage_Form1_Validator(theForm)
{

  if (theForm.FirstName.value == "")
  {
    alert("Please enter a value for the \"FirstName\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.FirstName.value.length > 256)
  {
    alert("Please enter at most 256 characters in the \"FirstName\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.LastName.value == "")
  {
    alert("Please enter a value for the \"LastName\" field.");
    theForm.LastName.focus();
    return (false);
  }

  if (theForm.LastName.value.length > 256)
  {
    alert("Please enter at most 256 characters in the \"LastName\" field.");
    theForm.LastName.focus();
    return (false);
  }

  if (theForm.Contact_Number.value == "")
  {
    alert("Please enter a value for the \"Contact_Number\" field.");
    theForm.Contact_Number.focus();
    return (false);
  }

  if (theForm.Contact_Number.value.length > 256)
  {
    alert("Please enter at most 256 characters in the \"Contact_Number\" field.");
    theForm.Contact_Number.focus();
    return (false);
  }

  var checkOK = "0123456789-.";
  var checkStr = theForm.Contact_Number.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  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 (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Contact_Number\" field.");
    theForm.Contact_Number.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please enter a valid number in the \"Contact_Number\" field.");
    theForm.Contact_Number.focus();
    return (false);
  }

  if (theForm.Email_Address.value == "")
  {
    alert("Please enter a value for the \"Email_Address\" field.");
    theForm.Email_Address.focus();
    return (false);
  }

  if (theForm.Email_Address.value.length > 256)
  {
    alert("Please enter at most 256 characters in the \"Email_Address\" field.");
    theForm.Email_Address.focus();
    return (false);
  }
  return (true);
}
