January 14, 2024 5:01 am

How to block Inappropriate content with javascript validation

If you are making a system where peoples come and give there reviews or accept content from public post, there is always some bad peoples write bad words and you have to manually manage these posts. Now with this article you will be able to manage inappropriate words and restrict peoples to write on website. Its a simple and easy to implement program hope you enjoy it.


[wpdm_file id=27]DEMO

create Bad word validation first create inappropriate.js File.

var words_array=new Array("bad","hate","wrong");
function badwords(txt)
 var arr=new Array;
 var count=0;
 var text=txt;
 for(var i=0; i<words_array.length; i++)
  for(var j=0; j<(text.length); j++)
 return count;

Javascript and HTML code.

<script type="text/javascript" src="inappropriate.js"></script>
<script type="text/javascript">
function Message()
var textbox_val=document.form.textbox.value;
alert("Please enter a message");
return false;

alert("Your message contains inappropriate words. 
Please clean up your message.");
return false;

<form action="thankyou.html" method="post"
onsubmit="return Message();" name="form">
<textarea name="textbox"></textarea>
<input type="submit" value=" Send "/>

I love to respond your comments.

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.

Tutorial Categories:

One response to “How to block Inappropriate content with javascript validation”

  1. Superlobster says:

    Good article. TBH usually the only thing I care to filter out is hyperlinks to spammy websites and the “we can boost your google ranking” guys.

Leave a Reply

Your email address will not be published. Required fields are marked *