How to : Create a BAD WORD filter in Blogger Comment

by Hough on June 4, 2011

How we do that ?

1,Go to Blogger Dashboard -> Design ->Edit HTML .Checked on Expand wiget templates . Backup template before making any changes .

2,Find <body> and add this code right before

<script type=’text/javascript’>
function badwordfilter(ID){
var comm = document.getElementById(ID);
var comment = comm.innerHTML;
var reBadWords = /badword1|badword2/gi;
comment1 = comment.replace(reBadWords, “****”);
comm.innerHTML = comment1; = “block”;

please pay attention to the text in black bold above,it’s the list of bad words .You can add more word to this list and separate each of them with a | ,like this
do not remove / at the start and /gi at the end .

3,Find and replace

<p>   <data:comment.body/></p>


<div expr:id=’’ style=’display:none;’>
<script type=’text/javascript’>badwordfilter(&quot;<>&quot;);</script>

That’s all .Save template and see the changes


Leave a Comment

Previous post:

Next post: