function checkForm() 
{
// check email part 1: field required
 if(document.frmContact.txtEmailAddress.value == "")
  {
    alert("Please enter your Email address.");
    document.frmContact.txtEmailAddress.focus();
    return false;
  }
// check email part 2: basic validation of formatting rules
 if ((document.frmContact.txtEmailAddress.value.indexOf(' ')  > -1) || // are there any spaces in the address
	  (document.frmContact.txtEmailAddress.value.indexOf('@') == -1) ||  // is the @ missing
     (document.frmContact.txtEmailAddress.value.indexOf('@') == 0) ||  // address can't start with an @
     (document.frmContact.txtEmailAddress.value.indexOf('@') != document.frmContact.txtEmailAddress.value.lastIndexOf('@')) || // is there more than one @
     (document.frmContact.txtEmailAddress.value.lastIndexOf('.') == -1) || // is the dot . missing
     (document.frmContact.txtEmailAddress.value.lastIndexOf('.') <= document.frmContact.txtEmailAddress.value.indexOf('@') + 1) ||  // is there nothing between the @ and the dot
     (document.frmContact.txtEmailAddress.value.lastIndexOf('.') >= document.frmContact.txtEmailAddress.value.length -2)) // the dot can't be one of the last two characters
   {
     alert("Sorry, this is not a valid Email address.");
     document.frmContact.txtEmailAddress.focus();
     return false;
   } 
 var invalid = "!#$%^&*()/:;,+";
 var is_invalid = "yes";
 var characters = "";
 for (var i=0; i < invalid.length; i++)
    {
        characters = invalid.charAt(i);
        if (document.frmContact.txtEmailAddress.value.indexOf(characters) > -1)
        {
            is_invalid = "no";
        }
    }
    if (is_invalid == "no")
    {
     alert("Sorry, there are invalid characters in your Email address.");
     document.frmContact.txtEmailAddress.focus();
     return false;
    }
  
  if(document.frmContact.txtMessage.value == "")
  {
	alert("Please write a message.");
	document.frmContact.txtMessage.focus();
	return false;
  }
  return true;
}
