function Validator(theForm)
{

  if (theForm.username.value == "")
  {
    alert("Please enter a value for the \"Username\" field.");
    theForm.username.focus();
    return (false);
  }

  if (theForm.username.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Username\" field.");
    theForm.username.focus();
    return (false);
  }

  if (theForm.username.value.length > 20)
  {
    alert("Please enter at most 20 characters in the \"Username\" field.");
    theForm.username.focus();
    return (false);
  }

	reWhiteSpace = new RegExp(/\s/);
	// Check for white space
	if (reWhiteSpace.test(theForm.username.value)) {
		alert("Username field has space. Please enter your \"Username\" without any space.");
	    theForm.username.focus();
		return false;
	}

  if (theForm.password.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }

  if (theForm.password.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }

  if (theForm.password.value.length > 15)
  {
    alert("Please enter at most 15 characters in the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }

  if (theForm.confirmpassword.value != theForm.password.value)
  {
    alert("Password and \"Confirm Password\" fields should have same value");
    theForm.confirmpassword.focus();
    return (false);
  }

  if (theForm.fullname.value == "")
  {
    alert("Please enter a value for the \"Fullname\" field.");
    theForm.fullname.focus();
    return (false);
  }

  if (theForm.fullname.value.length < 1)
  {
    alert("\"Fullname\" is too short or empty. Please enter your fullname");
    theForm.fullname.focus();
    return (false);
  }

  if (theForm.fullname.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Fullname\" field.");
    theForm.fullname.focus();
    return (false);
  }

  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email address\" field.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Email address\" field.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Email address\" field.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.confirmemail.value != theForm.email.value)
  {
    alert("\"E-mail address\" and \"Confirm E-mail address\" fields should have same value");
    theForm.confirmemail.focus();
    return (false);
  }

	if ( Validate_Email_Address(theForm.email.value) == false) 
	{
		alert ("\"Email addresss\" is not in valid format");
	    theForm.email.focus();
		return (false);
	}

	if ( Validate_Email_Address(theForm.confirmemail.value) == false) 
	{
		alert ("\"Confirm email addresss\" is not in valid format");
	    theForm.confirmemail.focus();
		return (false);
	}

  if (theForm.gender.selectedIndex < 0)
  {
    alert("Please select one of the \"Gender\" options.");
    theForm.gender.focus();
    return (false);
  }

  if (theForm.gender.selectedIndex == 0)
  {
    alert("The \"Gender\" option is not selected.  Please choose an appropriate option (either Male or Female)");
    theForm.gender.focus();
    return (false);
  }

  if (theForm.confirmgender.selectedIndex < 0)
  {
    alert("Please select one of the \"Confirm Gender\" options.");
    theForm.confirmgender.focus();
    return (false);
  }

  if (theForm.confirmgender.selectedIndex == 0)
  {
    alert("The \"Confirm Gender\" option is not selected.  Please choose an appropriate option (either Male or Female)");
    theForm.confirmgender.focus();
    return (false);
  }
  if (theForm.gender.selectedIndex != theForm.confirmgender.selectedIndex)
  {
    alert("You have selected two different values for \"Gender\" and  \"Confirm Gender\". Please choose same value for both options");
    theForm.confirmgender.focus();
    return (false);
  }
  return (true);
}
