//Checks if user put first and last name and if those names contain any swear.
function checkName(form)
{
  var firstName = getCookie('firstName');
  if (firstName == null)
  {
    firstName = form.firstNameBox.value;
  }
  
  var lastName = getCookie('lastName');
  if (lastName == null)
  {
    lastName = form.lastNameBox.value;
  }
  
  if ((firstName == "") || (lastName == ""))
  {
    alert ("Please enter your full name!");
    return false;
  }
  else
  {
    if ((firstName != null) && (lastName != null) && (containsSwearWords(firstName) || containsSwearWords(lastName)))
	{
	  alert ("Please do not use swear words!");
      return false;
	}
	else
	{
	  //if either first or last doesn't start with letter, or has 3 or more spaces , or doesn't have vowels, or has some special character, or has three or more same successive letters or four or more same successive numbers or has less than 3 characers.
      if ((!firstName.match(/^[a-z]/i) || !lastName.match(/^[a-z]/i)) || (firstName.match(/\s{3,}/) || lastName.match(/\s{3,}/)) || !firstName.match(/[a,e,i,o,u,y]/i) || !lastName.match(/[a,e,i,o,u,y]/i) || firstName.match(/[@,~,`,#,$,%,\^,&,\*,\(,\),-,_,=,+,\[,\{,\},\],\|,\\,;,:,",\,,<,>,\/,\?]/) || lastName.match(/[@,~,`,#,$,%,\^,&,\*,\(,\),-,_,=,+,\[,\{,\},\],\|,\\,;,:,",\,,<,>,\/,\?]/) || firstName.match(/(a{3,})|(b{3,})|(c{3,})|(d{3,})|(e{3,})|(f{3,})|(g{3,})|(h{3,})|(i{3,})|(j{3,})|(k{3,})|(l{3,})|(m{3,})|(n{3,})|(o{3,})|(p{3,})|(q{3,})|(r{3,})|(s{3,})|(t{3,})|(u{3,})|(v{3,})|(w{3,})|(x{3,})|(y{3,})|(z{3,})|(0{4,})|(1{4,})|(2{4,})|(3{4,})|(4{4,})|(5{4,})|(6{4,})|(7{4,})|(8{4,})|(9{4,})|(\.{2,})|(!{2,})|('{3,})/i) || lastName.match(/(a{3,})|(b{3,})|(c{3,})|(d{3,})|(e{3,})|(f{3,})|(g{3,})|(h{3,})|(i{3,})|(j{3,})|(k{3,})|(l{3,})|(m{3,})|(n{3,})|(o{3,})|(p{3,})|(q{3,})|(r{3,})|(s{3,})|(t{3,})|(u{3,})|(v{3,})|(w{3,})|(x{3,})|(y{3,})|(z{3,})|(0{4,})|(1{4,})|(2{4,})|(3{4,})|(4{4,})|(5{4,})|(6{4,})|(7{4,})|(8{4,})|(9{4,})|(\.{2,})|(!{2,})|('{3,})/i) || ((firstName.length < 3) || (lastName.length < 3)))
	  {
	    alert ("Please enter a valid name!");
        return false;
	  }
	  else
	  {
	    return true;
	  }
	}
  }
}

//Checks if the user put valid date of birth.
function checkDOB(form)
{
  var dOB = getCookie('dOB');
  if (dOB == null)
  {
    dOB = form.dOBBox.value;
  }
  
  if (!validDOB(dOB))
  { 
	alert ("Please enter a valid Date of Birth!");
	return false;
  }
  else
  {
	return true;
  }
}