Detecting Profanity and Bad Words

Hi all. Working on a cool magic 8ball app and wanted to detect and bad/swear words in the input text. I’ve put all the bad words I can think of in an array calls badWords and then it will detect and entry from this array on press of the submit button… only problem the script doesn’t seem to be detecting the swears. Could someone give me some help. Thanks.

The way it should work is when you enter a question it will detect if a swear word is present from my badWords array, if not then it will put a random answer in the answer box from the myAnswers_array…

badWord = ARRAY OF BAD WORDS
myAnswers_array = ARRAY OF ANSWERS TO YOUR 8 BALL QUESTIONS
myAskButton = BUTTON WHICH YOU PRESS TO GENERATE AN ANSWER
myQuestionsField = INPUT TXT, WHERE YOU ENTER YOUR QUESTIONS
myAnswerTextField = DYNAMIC TXT, WHERE THE ANSWERS APPEAR


// bar words
badWords = ["cat", "dogs", "bunnies", "cats"];
 
// Possible Answers. To be called at random later
myAnswers_array = ["Yes", "No", "Maybe", "Definately", "Without a doubt", "Heck no", "Most Absolutely", "Certainly Not", "Its anybody's guess", "What do you think?"];
 
// sets ask question button to invisible if there is
// no entry in the question field.
myAskButton._visible = false;
TextField.prototype.isEmpty = function() {
	 return !Boolean(this.length);
};
 
// If there is something in the questions text field
// then make the "ask" button visible
myQuestionsField.onChanged = function() {
	 myAskButton._visible = !this.isEmpty();
};
 
// When you press the "ask button" it will call up the
// random answers from the array "myAnswers_array"
myAskButton.onPress = function() {
	 for (i in badWords) {
		  if (myQuestionsField.indexOf(badWords*)> -1) {
		  myQuestionsField.text = "";
		  myAnswerTextField.text = "Swearing is a bad habbit";
		  trace("swear detected");
		  } else {
			   var index = random(myAnswers_array.length);
			   myAskButton._visible = false;
			   myQuestionsField.text = "";
			   myAnswerTextField.text = myAnswers_array[index];
			   trace("swear NOT detected");
		  }
	 }
};