// JavaScript Document
<!--
function Form_Validator(theForm)
{
//--------------------> VALIDATE FOR COMPANY INFORMATION
  if (theForm.company_name.value == "")
  {
    alert("Please enter a value for the \"Company Name\" field.");
    theForm.company_name.focus();
    return (false);
  }
  
   if (theForm.contact_method.value == "")
  {
    alert("Please enter a value for the \"Preferred Contact Method\" field.");
    theForm.contact_method.focus();
    return (false);
  }
  
  if (theForm.company_address.value == "")
  {
    alert("Please enter a value for the \"Company Address\" field.");
    theForm.company_address.focus();
    return (false);
  }
  
  if (theForm.company_city.value == "")
  {
    alert("Please enter a value for the \"Company City\" field.");
    theForm.company_city.focus();
    return (false);
  } 
   
  if (theForm.company_state.value == "")
  {
    alert("Please enter a value for the \"Company State\" field.");
    theForm.company_state.focus();
    return (false);
  }
  
  if (theForm.company_zip.value == "")
  {
    alert("Please enter a value for the \"Company Zip Code\" field.");
    theForm.company_zip.focus();
    return (false);
  }
  
  if (theForm.company_phone.value == "")
  {
    alert("Please enter a value for the \"Company Phone\" field.");
    theForm.company_phone.focus();
    return (false);
  }
  
  if (theForm.contact_name.value == "")
  {
    alert("Please enter a value for the \"Contact Name\" field.");
    theForm.contact_name.focus();
    return (false);
  }
  
  if (theForm.contact_email.value == "")
  {
    alert("Please enter a value for the \"Contact Email\" field.");
    theForm.contact_email.focus();
    return (false);
  }

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


//--------------------> VALIDATE FOR PART INFORMATION
  

//------------------------------------------------------------------------------------------------------>


  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ";
  var checkStr = theForm.State.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 letter characters in the \"State\" field.");
    theForm.State.focus();
    return (false);
  }
  return (true);
}
//-->
function MailList_validation(theForm)
{
//--------------------> VALIDATE FOR COMPANY INFORMATION

   if (theForm.company.value == "")
  {
    alert("Please enter a value for the \"Company Name\" field.");
    theForm.company.focus();
    return (false);
  }
  
  if (theForm.contact_email.value == "")
  {
    alert("Please enter a value for the \"Contact Email\" field.");
    theForm.contact_email.focus();
    return (false);
  }
  var valid_email = email_check (theForm.contact_email.value);
  if (valid_email == false)
  {
    theForm.contact_email.focus();
    return (false);
  }
  
  if (theForm.address.value == "")
  {
    alert("Please enter a value for the \"Company Address\" field.");
    theForm.address.focus();
    return (false);
  }
  
  if (theForm.city.value == "")
  {
    alert("Please enter a value for the \"Company City\" field.");
    theForm.city.focus();
    return (false);
  } 
   
  if (theForm.state.value == "")
  {
    alert("Please enter a value for the \"Company State\" field.");
    theForm.state.focus();
    return (false);
  }
  
  if (theForm.zip.value == "")
  {
    alert("Please enter a value for the \"Company Zip Code\" field.");
    theForm.zip.focus();
    return (false);
  }
  
  if (theForm.phone.value == "")
  {
    alert("Please enter a value for the \"Company Phone\" field.");
    theForm.phone.focus();
    return (false);
  }

 
  return (true);
}
//___________________________________________________________________________________________

function email_check(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
}
//-->