Forum Moderators: coopster
I realize this will not stop hackers or determined spammers but I'd like to implement it as part of my efforts to keep a site clean. Sometimes asking people to self moderate actually works. The benefit is that if they self moderate when asked to do so the database remains clean and resources are saved.
This is my best working effort thus far...
badwords = new Array("bad", "words", "here", "etc");
function Verify(aaa)
{
tvalue = aaa.title.value; // entered words
// check if title field is empty
if (tvalue == "")
{
alert("Please include an accurate title");
aaa.title.focus();
return false;
}
fvalue = aaa.description.value; // entered words
// check if description field is empty
if (fvalue == "")
{
alert("Please include an accurate description of your upload");
aaa.description.focus();
return false;
}
// title and description are not empty so check for badwords in description
else
{
wordsArray = fvalue.split(" ");
for (i = 0; i < badwords.length; i++)
{
for ( j=0; j < wordsArray.length; j++)
{
if (wordsArray[j] == badwords[i])
{
alert("Please keep descriptions clean, self moderation means no forced moderation!");
aaa.description.focus();
return false;
}
}
}
} // end check for badwords
}
The form uses onsubmit="return Verify(this)" to run the function.
It's unfortunately case sensitive and I'd like to ask your help in making it case insensitive (or to make it more efficient). Any suggestions welcome.
if (wordsArray[j].toLowerCase() == badwords[i].toLowerCase()){}