Friday, October 20, 2006

Add some javascript codes to limit bad posts

The post platform of my Company website got many bad messages which were prohibited by the goverment. So I add some simple code in the page to limit these bad messages posted in our site. Write down the words you don't want in the first line, spiting them with "|"


var kws = "XXX|XXX|XXX";
function check(theForm)
{
if (eval("/"+kws+"/gi.test(theForm.product1.value)"))
{alert("Your content includes bad words"); return false;}

else if (eval("/"+kws+"/gi.test(theForm.product.value)"))
{alert("Your content includes bad words"); return false;}

else if (eval("/"+kws+"/gi.test(theForm.memo.value)"))
{alert("Your content includes bad words"); return false;}

else return true;
}

No comments: