This is the second version of checkForProfanity. It still checks to make sure that no bad words are entered, but this one is much easier to use. Just copy the code for the
event exactly as shown:
onBlur = "this.value = checkForProfanity(this.value);"
and stick it in the
tag. That's all.
Also, the variables are easier to use:
is a variable that holds the message that will overwrite the contents of the
tag if a swear word is written.
is the total number of swear words that you do not want to appear in the text box. To add more words, just add to the array as the code shows.
Now enough talk, try typing a swear word in that field.