Friday, April 13, 2018

Filter Bad Words in JavaScript

Here is a sample script to filter bad words from a sentence given by our user using JavaScript

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Program Listing

filter.htm

<html>
<head>
<title>Filter Bad Words in JavaScript</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script language="javascript">
message=prompt("Filter “fool, idiot, imbecile and moron” words. Please enter your message: ","");
subsitude = /fool|idiot|imbecile|moron|fuck/g;
if (message.match(subsitude)){
message=message.replace(subsitude,"master");
message=message.bold().fontcolor("#FF0000");
myText="Your message has a ungraceful word, which has been replaced by: " + message;
}
else{
message=message.bold().fontcolor("#0000FF");
myText="Yor message has no ungraceful word, you said:  " + message;
}
</script>
</head>
<body>
<script language="javascript">
document.write(myText)
</script>
<br>
</body>
</html>



No comments:

Post a Comment