﻿function TechHelpValidator(theForm)


{
  var checkStr = theForm.TechHelpName.value;
  var allValid = true;
  
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    if (ch == "'")
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please put a space instead of ' in the Name field.");
    theForm.TechHelpName.focus();
    return (false);
  }


  if (theForm.TechHelpName.value == "")
  {
    alert("Please enter your full name in the \"Name\" field.");
    theForm.TechHelpName.focus();
    return (false);
  }

  if (theForm.TechHelpName.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"Name\" field.");
    theForm.TechHelpName.focus();
    return (false);
  }

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


  


 if (theForm.TechHelpOrganization.value == "")
  {
    alert("Please enter the name of your organization or company in the \"Organization/Company\" field.");
    theForm.TechHelpOrganization.focus();
    return (false);
  }

  if (theForm.TechHelpOrganization.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"Organization\" field.");
    theForm.TechHelpOrganization.focus();
    return (false);
  }

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

  





  if (theForm.TechHelpEmail.value == "")
  {
    alert("Please enter your email address in the \"Email Address\" field.");
    theForm.TechHelpEmail.focus();
    return (false);
  }

/* TEST: COMMENT OUT FOR NOW

  if (theForm.TechHelpEmail.value.length < 8)
  {
    alert("Please enter at least 8 characters in the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.TechHelpEmail.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  var checkStr = theForm.TechHelpEmail.value;
  
  if (checkStr.charAt(0) == " ")
  {
    alert("Please do not put space before your email address.");
    theForm.TechHelpEmail.focus();
    return (false);
  }
*/

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz??????????????????????????????????????????????????????????????????????0123456789-@_.";
  var checkStr = theForm.TechHelpEmail.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 letters, digits and @._- characters in the \"Email Address\" field.");
    theForm.TechHelpEmail.focus();
    return (false);
  }

  var checkStr = theForm.TechHelpEmail.value;
  var emailValid1 = false;
  var emailValid2 = false;

  for (i = 0;  i < checkStr.length;  i++)
  { 
 	ch = checkStr.charAt(i);
 	if (ch == "@")
 	  {
 	   emailValid1 = true;
  	   break;
  	  }
  }

  for (i = 0;  i < checkStr.length;  i++)
  { 
 	ch = checkStr.charAt(i);
 	if (ch == ".")
     {
	   emailValid2 = true;
 	   break;
 	  }
  }
  if (emailValid1 == false || emailValid2 == false)
  {
	alert("Please enter your email address properly.");
   theForm.TechHelpEmail.focus();
   return (false);
  }
 
 
 
 
 
  
 /*  TEST: AREA CODE VARIABLES PLACED HERE  */
  
   var checkOK = "0123456789-";
  var checkStr = theForm.TechHelpAreaCode.value;
  var allValid = true;
  var validGroups = 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 digit characters in the \"Area Code\" field.");
    theForm.TechHelpAreaCode.focus();
    return (false);
  }
   
  
  

 
 if (theForm.TechHelpAreaCode.value == "")
  {
    alert("Please enter your area code in the \"Area Code\" field.");
    theForm.TechHelpAreaCode.focus();
    return (false);
  }

  if (theForm.TechHelpAreaCode.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Area Code\" field.");
    theForm.TechHelpAreaCode.focus();
    return (false);
  }

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

  


  
  
  
   /*  TEST: PHONE NUMBER VARIABLES PLACED HERE  */
   
     var checkOK = "0123456789--";
  var checkStr = theForm.TechHelpPhone.value;
  var allValid = true;
  var validGroups = 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 digit and \"-\" characters in the \"Telephone\" field.");
    theForm.TechHelpPhone.focus();
    return (false);
  }
  
  
  

  if (theForm.TechHelpPhone.value == "")
  {
    alert("Please enter your telephone number in the \"Telephone\" field.");
    theForm.TechHelpPhone.focus();
    return (false);
  }

  if (theForm.TechHelpPhone.value.length < 7)
  {
    alert("Please enter at least 7 characters in the \"Telephone\" field.");
    theForm.TechHelpPhone.focus();
    return (false);
  }

  if (theForm.TechHelpPhone.value.length > 8)
  {
    alert("Please enter at most 8 characters in the \"Telephone\" field.");
    theForm.TechHelpPhone.focus();
    return (false);
  }
  
  
  
  
    /*  TEST: COMMENTS VARIABLES ADDED HERE  
	
	

{
  var checkStr = theForm.TechHelpComments.value;
  var allValid = true;
  
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    if (ch == "'")
    {
      allValid = false;
      break;
    }
  }
  
  
  */ 
  
  

  if (theForm.TechHelpComments.value == "")
  {
    alert("Please describe the problem in the field provided for this.");
    theForm.TechHelpComments.focus();
    return (false);
  }
  
	
/* TEST: COMMENTING OUT THIS PART - When I commented out the last lines, it didn't work anymore */


  return (true);
}

