Skip to content

Instantly share code, notes, and snippets.

@pridemusvaire
Forked from stevereich/wordFilter.cfm
Created August 30, 2016 15:10
Show Gist options
  • Save pridemusvaire/e50a786ab03e91b4796eafb6228dc354 to your computer and use it in GitHub Desktop.
Save pridemusvaire/e50a786ab03e91b4796eafb6228dc354 to your computer and use it in GitHub Desktop.
Form to demonstrate the bad word filter.cfc
<html>
<head>
<title>Bad Word Filter</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script language="JavaScript" type="text/javascript">
$(function(){
$filterBox = $('#filterBox');
$frmWords = $('#frmWords');
$thewords = $('#thewords');
$buttonCheck = $('#buttonCheck').click(function(){
if($filterBox.val() != ''){
$.ajax({
type: "POST",
url: "ajax_badwords.cfm",
data: $frmWords.serialize(),
dataType: 'json',
cache: false,
success: function(msg){
if(msg.wordsRemoved != ''){
$thewords.val(msg.wordsRemoved);
alert("The following words are not allowed and will be removed:\n\n" + $thewords.val());
$filterBox.val(msg.newString);
}
else{
alert("There are no offensive words. You are safe.");
}
},
error: function(a){
alert("Error:\n" + a.status + ": " + a.statusText);
}
});
}
else{
alert('You have to type somthing first! Go ahead.. get dirty!')
}
});
})
</script>
</head>
<body>
<div style="margin:auto;text-align:left;width:100%px">
<form id="frmWords">
<span style="font-family:Calibri;font-weight:bold">Bad word filter... go ahead, get dirty! I'll clean it up!</span><br>
<textarea id="filterBox" name="filterBox" style="width:100%;height:100px"></textarea><br /><br />
<input type="hidden" value="" id="thewords" name="thewords">
<input type="radio" value="0" name="replaceString"> Replace bad words with *<br />
<input type="radio" value="1" name="replaceString" checked> Replace bad words with &^#*@$#<br /><br />
<input type="button" id="buttonCheck" value="Clean It Up!"> <input type="reset" value="Clear Text">
</form>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment