// JAVASCRIT - Version 2

function formValidator(theForm)
{

  if (theForm.client_name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.client_name.select();
    theForm.client_name.focus();
    return (false);
  }

  // require at least 3 characters be entered
  if (theForm.client_name.value.length < 3)	
  {
    alert("Please make sure that \"Name\" field was properly completed.");    
    theForm.client_name.select();
    theForm.client_name.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.client_name.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.client_name.select();
    theForm.client_name.focus();
    return (false);
  }

 //**********************************************8
 
 
  if (theForm.client_centre.value == "")
  {
    alert("Please enter a value for the \"Centre\" field.");
    theForm.client_centre.select();
    theForm.client_centre.focus();
    return (false);
  }

  // require at least 3 characters be entered
  if (theForm.client_name.value.length < 3)	
  {
    alert("Please make sure that \"Centre\" field was properly completed.");    
    theForm.client_centre.select();
    theForm.client_centre.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.client_centre.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 \"Centre\" field.");
    theForm.client_centre.select();
    theForm.client_centre.focus();
    return (false);
  }

 
 
 
 
 
 
 
 
 
 //*************************************************
  // check if email field is blank
  var Email=theForm.client_email.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.client_email.select();
	theForm.client_email.focus();
  	return false;
    }

  }
  else
  {
   alert("Please enter a value for the \"E-Mail\" field."); 
   theForm.client_email.select();
   theForm.client_email.focus();
   return false;
  }



  //**********************************************
 
 
 
}
