// JAVASCRIT - Version 2

function formValidator(theForm)
{

  if (theForm.FullName.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.FullName.select();
    theForm.FullName.focus();
    return (false);
  }

  // require at least 3 characters be entered
  if (theForm.FullName.value.length < 3)	
  {
    alert("Please make sure that \"Name\" field was properly completed.");    
    theForm.FullName.select();
    theForm.FullName.focus();
    return (false);
  }

  // allow ONLY alphabets, no symbols or punctuation
  // this can be altered for any "checkOK" string you desire
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
  var checkStr = theForm.FullName.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 alphabets and spaces in the \"Name\" field.");
    theForm.FullName.select();
    theForm.FullName.focus();
    return (false);
  }


  if (theForm.CompanyName.value == "")
  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.CompanyName.focus();
    return (false);
  }

  if (theForm.CompanyName.value.length < 2)
  {
    alert("Please make sure that \"Company\" field was properly completed.");
    theForm.CompanyName.select();
    theForm.CompanyName.focus();
    return (false);
  }

 
  if (theForm.City.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.City.value.length < 2)
  {
    alert("Please make sure that \"City\" field was properly completed.");
    theForm.City.select();
    theForm.City.focus();
    return (false);
  }

// check to see if the Product field is blank
 if(theForm.Country.selectedIndex == 0)
	{
		alert("Please select the Country");
		theForm.Country.focus();
		return(false);
		flag=true;
	}


// check if email field is blank
  var Email=theForm.Mail.value;
  if(Email != "")
  {
   if( (Email.indexOf('@',0) ==-1) || (Email.indexOf('.',0) ==-1))
    {
 	alert("The \"E-Mail\" field is invalid, please try again. It must contain an \"@\" and a \".\" ");
 	theForm.Mail.select();
	theForm.Mail.focus();
  	return false;
    }

  }
  else
  {
   alert("Please enter a value for the \"E-Mail\" field."); 
   theForm.Mail.select();
   theForm.Mail.focus();
   return false;
  }

// check to see if the Product field is blank
 if(theForm.Products.selectedIndex == 0)
	{
		alert("Please select the Product");
		theForm.Products.focus();
		return(false);
		flag=true;
	}
// check to see if the Window Edition field is blank
 if (theForm.WindowEdition.value == "")
  {
    alert("Please enter a value for the \"Window Edition\" field.");
    theForm.WindowEdition.focus();
    return (false);
  }

  if (theForm.WindowEdition.value.length < 2)
  {
    alert("Please make sure that \"Window Edition\" field was properly completed.");
    theForm.WindowEdition.select();
    theForm.WindowEdition.focus();
    return (false);
  }

// check Description
 if (theForm.Description.value == "")
  {
    alert("Please enter a value for the \"Description\" field.");
    theForm.Description.focus();
    return (false);
  }

 
  return (true);
}
