Forum Moderators: open
$filter=array("badword1", "badword2");
for ($i = 0; $i < count($filter); $i++) {
if (preg_match("/\b".$filter[$i]."\b/i", $comments)) {
$profanity_msg="Profanity is not allowed";
}
}
//Then this before the form
if(isset($profanity_msg)){
echo $profanity_msg;
}
$(document).ready(function(){
//custom validation rule - profanity
$.validator.addMethod("profanity",
"Equivalent of my php function goes here..."
);
//validation implementation will go here.
$("#TestForm").validate({
rules: {
comments: {
required: true,
profanity: true
}
},
messages: {
comments: {
required: "* Required",
profanity: "* No Profanity Allowed"
}
}
});
})
function censor(text)
{
var badwords = ['badword1','badword2','badword3'];
for (var i in badwords)
{
var word = badwords[i];
var replacement = word.substr(0,0);
for (var j = 1; j< word.length; j++) {replacement += '*';}
word = new RegExp(word,'gi');
text = text.replace(word,replacement);
}
return text;
}
it's always 70KB
HTTP/1.0 200 OK
Accept-Ranges: bytes
Content-Encoding: gzip
Content-Type: application/x-javascript; charset=utf-8
Date: Sun, 27 Feb 2011 12:21:15 GMT
ETag: "32404f4-14d0c-a5998700+gzip"
Last-Modified: Wed, 23 Feb 2011 18:55:56 GMT
Server: ECS (ord/5734)
Vary: Accept-Encoding
X-Cache: HIT
Content-Length: 29715
Connection: keep-alive