function checkForm (target)
{
        var name = document.getElementById("name");
        var email = document.getElementById("email");
        var comment = document.getElementById("comment");
        var form = document.getElementById("form");

        if (name.value.toString() == "" || email.value.toString() == "" || comment.value.toString() == "")
        {
                alert("Please enter all your details in their respective fields before submitting the form. Thank you.");
                if (name.value.toString() == "") { name.focus(); }
                else if (email.value.toString() == "") { email.focus(); }
                else if (comment.value.toString() == "") { comment.focus(); }
        }
        else
        {
                var invalid1 = "<";
                var invalid2 = ">";
                var name1 = false;
                var name2 = false;
                var email1 = false;
                var email2 = false;
                var comment1 = false;
                var comment2 = false;

                var i = 0;
                for (i = 0; i < name.value.length; i++)
                      {
                              if (name.value.toString().charAt(i) == "<")
                         {
                                 name1 = true;
                         }
                        else if (name.value.toString().charAt(i) == ">")
                        {
                                name2 = true;
                        }
                      }
                var j = 0;
                for (j = 0; j < email.value.length; j++)
                      {
                              if (email.value.toString().charAt(j) == "<")
                         {
                                 email1 = true;
                         }
                        else if (email.value.toString().charAt(j) == ">")
                        {
                                email2 = true;
                        }
                      }
                var h = 0;
                for (h = 0; h < comment.value.length; h++)
                      {
                              if (comment.value.toString().charAt(h) == "<")
                         {
                                 comment1 = true;
                         }
                        else if (comment.value.toString().charAt(h) == ">")
                        {
                                comment2 = true;
                        }
                      }


                if ((name1 == true && name2 == true) ||
                (email1 == true && email2 == true) ||
                (comment1 == true && comment2 == true))
                {
                        alert("Please note that html code is not allowed in this form! Please remove it and resubmit.");
                }
                else
                {
                        if ((name.value.toString().search("http") != -1 || email.value.toString().search("http") != -1 || comment.value.toString().search("http") != -1) || (name.value.toString().search("href") != -1 || email.value.toString().search("href") != -1 || comment.value.toString().search("href") != -1) || (name.value.toString().search("://") != -1 || email.value.toString().search("://") != -1 || comment.value.toString().search("://") != -1))
                        {
                                alert("No html links are allowed in this form! Please remove them and resubmit.");
                        }
                        else
                        {
                                if (IsText(name) == false)
                                {
                                        alert("Please only enter valid characters in your name.");
                                }
                                else
                                {
                                        form.submit();
                                }
                        }
                }
        }
}

function IsText(txt)

{
   var ValidChars = "abcdefghijklmnopqrstuvwxyz-'ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var isText = true;
   var sText = txt.value;
   var Char;


   for (i = 0; i < sText.length && isText == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
                 isText = false;
         }
      }
   return isText;
}
