function form_submit(theForm)
{
   theForm.submit();
}

function join_Validator(theForm)
{
  var alertsay = ""; // define for long lines

  // check to see if the field Account is blank
  if (theForm.username.value == "")
  {
    alert("Username should not be empty");
    theForm.username.focus();
    return (false);
  }

  // require at least 5 characters be entered
  if (theForm.username.value.length < 5)
  {
    alert("Username should be at least 5 characters.");
    theForm.username.focus();
    return (false);
  }

  // allow ONLY alphanumeric keys, no symbols or punctuation
  // this can be altered for any "checkOK" string you desire
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
  var checkStr = theForm.username.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("Username should contain characters and number only.");
    theForm.username.focus();
    return (false);
  }

  // require at least 5 characters in the password field
  if (theForm.passwd.value.length < 5)
  {
    alert("Password should be at least 5 characters.");
    theForm.passwd.focus();
    return (false);
  }

  // allow ONLY alphanumeric keys, no symbols or punctuation
  // this can be altered for any "checkOK" string you desire
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
  var checkStr = theForm.passwd.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("Password should contain characters and numbers only.");
    theForm.passwd.focus();
    return (false);
  }

  // Check if password = username, if so, display error msg
  if (theForm.username.value == theForm.passwd.value)
  {
        alert("Username and Password should not be same.");
        theForm.passwd.focus();
        return (false);
  }

  // check if both password fields are the same
  if (theForm.passwd.value != theForm.passwd2.value)
  {
        alert("Password and Verify Password are not same.");
        theForm.passwd2.focus();
        return (false);
  }

// check if email field is blank
  if (theForm.email.value == "")
  {
    alert("Email is blank.");
    theForm.email.focus();
    return (false);
  }

// test if valid email address, must have @ and .
  var checkEmail = "@.";
  var checkStr = theForm.email.value;
  var EmailValid = false;
  var EmailAt = false;
  var EmailPeriod = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkEmail.length;  j++)
    {
      if (ch == checkEmail.charAt(j) && ch == "@")
        EmailAt = true;
      if (ch == checkEmail.charAt(j) && ch == ".")
        EmailPeriod = true;
          if (EmailAt && EmailPeriod)
                break;
          if (j == checkEmail.length)
                break;
        }

   // if both the @ and . were in the string
    if (EmailAt && EmailPeriod)
    {
                EmailValid = true
                break;
        }
  }
  if (!EmailValid)
  {
    alert("Please input valid email address.");
    theForm.email.focus();
    return (false);
  }


   return (true);
}

