Here is a simple JavaScript form validation to check for any illegal words or character before a form is submitted.
var myRegExp = /http|www|url|<a|href/;
var value_a = document.form1.coms.value;
var string1 = value_a;
var matchPos1 = string1.search(myRegExp);
if((matchPos1 != -1) || (document.form1.coms.value == ""))
{
alert("You need to input a comment or your comment contains illegal characters or words, you cannot use http language, url links, emails or abusive words or references which we feel is un suitable for this post");
return false;
}