BeloglazowaYlya
New Member
I have a form that pop ups for users to leave comments on videos. Inside the form where people enter the message there is a profanity filter in place. It works fine and catches the word if it is in the message. My question is if there is a way to highlight the word that is caught so the user can see which one was considered profane?Here is the message being formed and going through the filter:\[code\] if (context.Request["postform"] == "1") { ProfanityFilter filter = new ProfanityFilter(); // IF NEITHER THE MESSAGE OR FIRSTNAME CONTAINS ANY PROFANITY IN THEM if (filter.containsProfanity(context.Request["message"]) == false && filter.containsProfanity(context.Request["first_name_submitter"]) == false) { videomessage myVideoMessage = new videomessage(); myVideoMessage.video_id = context.Request["video_id"]; myVideoMessage.first_name_submitter = context.Request["first_name_submitter"]; myVideoMessage.last_initial_submitter = context.Request["last_initial_submitter"]; myVideoMessage.message = context.Request["message"]; myVideoMessage.status = "0"; myVideoMessage.Save(); return_success = "1"; } else { return_success = "0"; return_errormessage = "<span>Contains profanity</span>"; } }\[/code\]And here is the ProfanityFilter class:\[code\]public class ProfanityFilter{ // *********************************************************************** // CONSTRUCTORS public ProfanityFilter() { } // *********************************************************************** // ************************************************************************ // METHOD: containsProfanity public bool containsProfanity(string checkStr) { bool badwordpresent = false; string[] inStrArray = checkStr.Split(new char[] { ' ' }); string[] words = this.profanityArray(); // LOOP THROUGH WORDS IN MESSAGE for (int x = 0; x < inStrArray.Length; x++) { // LOOP THROUGH PROFANITY WORDS for (int i = 0; i < words.Length; i++) { // IF WORD IS PROFANITY, SET FLAG AND BREAK OUT OF LOOP //if (inStrArray[x].toString().toLowerCase().equals(words)) if( inStrArray[x].ToLower() == words.ToLower() ) { badwordpresent = true; break; } } // IF FLAG IS SET, BREAK OUT OF OUTER LOOP if (badwordpresent == true) break; } return badwordpresent; } // ************************************************************************ // ************************************************************************ // METHOD: profanityArray() // METHOD OF PROFANITY WORDS private string[] profanityArray() { string[] words = { // ARRAY OF WORDS };return words;}}\[/code\]Is there a way to add something in the \[code\]else\[/code\] to highlight the word? Or even just change its color from black to red?Thank you in advance!