// Form Validator
function form_val_reg(theForm)
{

  if (theForm.pword.value == "")
  {
    alert("Please provide a password of your choice in the \"Password\" box.");
    theForm.pword.focus();
    return (false);
  }

  if (theForm.pword.value.length < 5)
  {
    alert("Please enter at least 5 characters or numbers or combination thereof in the \"Password\" box.");
    theForm.pword.focus();
    return (false);
  }
  
  if (theForm.fname.value == "")
  {
    alert("Please provide your first name in the \"First Name\" box.");
    theForm.fname.focus();
    return (false);
  }

  if (theForm.fname.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"First Name\" box.");
    theForm.fname.focus();
    return (false);
  }
  
      if (theForm.lname.value == "")
  {
    alert("Please provide your last name in the \"Last Name\" box.");
    theForm.lname.focus();
    return (false);
  }

  if (theForm.lname.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Last Name\" box.");
    theForm.lname.focus();
    return (false);
  }

 if (theForm.myCompany.value == "")
  {
    alert("Please enter your company name in the  \"Company\" field.");
    theForm.myCompany.focus();
    return (false);
  }

  if (theForm.myCompany.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Company\" field.");
    theForm.myCompany.focus();
    return (false);
  }

  if (theForm.Post_Code.value == "")
  {
    alert("Please provide your Post Code the \"Post_Code\" box.");
    theForm.Post_Code.focus();
    return (false);
  }

  if (theForm.Post_Code.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Post_Code\" box.");
    theForm.Post_Code.focus();
    return (false);
  }

  if (theForm.Telephone.value == "")
  {
    alert("Please provide a valid telephone or mobile number in the \"Telephone\" box.");
    theForm.Telephone.focus();
    return (false);
  }

  if (theForm.Telephone.value.length < 9)
  {
    alert("Please enter at least 9 characters in the \"Telephone\" box.");
    theForm.Telephone.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = theForm.Telephone.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 if (ch == "," && decPoints != 0)
    {
      validGroups = false;
      break;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Telephone\" box.");
    theForm.Telephone.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please provide a valid telephone or mobile number in the \"Telephone\" box.");
    theForm.Telephone.focus();
    return (false);
  }

  if (theForm.Email.value == "")
  {
    alert("Please provide your valid email address in the \"Email\" box.");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Email.value.length < 6)
  {
    alert("Please provide at least 6 characters in the \"Email\" box.");
    theForm.Email.focus();
    return (false);
  }

   return (true);
}