-
-
Save pridemusvaire/e50a786ab03e91b4796eafb6228dc354 to your computer and use it in GitHub Desktop.
Form to demonstrate the bad word filter.cfc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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