Home Web Front-end JS Tutorial JavaScript method to automatically block sensitive words on the page_javascript skills

JavaScript method to automatically block sensitive words on the page_javascript skills

May 16, 2016 pm 03:48 PM
javascript shield Sensitive words

The example in this article describes how JavaScript can automatically block sensitive words on the page. Share it with everyone for your reference. The details are as follows:

<html>
<head>
 <title>Bad Words Example</title>
 <script type="text/javascript">
   function filterText(sText) {
    var reBadWords = /badword|anotherbadword/gi;
    return sText.replace(reBadWords, "****");
   }
   function showText() {
    var oInput1 = document.getElementById("txt1");
    var oInput2 = document.getElementById("txt2");
    oInput2.value = filterText(oInput1.value);
   }
 </script>
</head>
<body>
 <P>
 <textarea rows="10" cols="50" id="txt1">badword anotherbadword</textarea><br />
 <input type="button" value="Filter Bad Words" onclick="showText()" /></p>
 <P>Filtered Text:<br />
 <textarea rows="10" cols="50" id="txt2"></textarea></p>
</body>
</html>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
How to block advertisement push in WeChat Moments How to turn off advertisements in WeChat Moments How to block advertisement push in WeChat Moments How to turn off advertisements in WeChat Moments Mar 12, 2024 pm 01:50 PM

We need to use WeChat APP all the time every day. The functions here are rich and diverse, not only for everyone to chat here, but also for you to handle various things in life. They can solve some problems very well, and their lives can become better and better. Nowadays, everyone still likes to check the circle of friends. You will find that there are some life updates posted by your friends on the circle of friends. information, record some of your wonderful life, and set the visibility range of your Moments. You can view these Moments within a specified time. It is your own decision. Every time you check your Moments, you will be able to discover something. Everyone is very irritated by the advertising push interface and wants to close it.

How to implement an online speech recognition system using WebSocket and JavaScript How to implement an online speech recognition system using WebSocket and JavaScript Dec 17, 2023 pm 02:54 PM

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems WebSocket and JavaScript: key technologies for implementing real-time monitoring systems Dec 17, 2023 pm 05:30 PM

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

How to set up text message blocking on iPhone How to set up text message blocking on iPhone Feb 24, 2024 pm 01:48 PM

With the popularity of smart phones, we receive a large number of text messages every day, some of which are advertising and promotional messages, and some of which are spam text messages. These text messages not only waste our time, but also occupy the space of our mobile phones. Fortunately, however, iPhones offer some features to block these annoying text messages. This article will introduce how to block text messages using iPhone. To block text messages, first open the Settings app, then scroll and tap Messages. In the information settings interface, you can see some options, including "Blocked

How to use JavaScript and WebSocket to implement a real-time online ordering system How to use JavaScript and WebSocket to implement a real-time online ordering system Dec 17, 2023 pm 12:09 PM

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to block friends in Tantan's mobile address book? Setting steps for blocking mobile contacts How to block friends in Tantan's mobile address book? Setting steps for blocking mobile contacts Mar 12, 2024 pm 03:55 PM

We all particularly like the Tantan social platform. It is very safe and reliable. We can all make a lot of friends on the Internet here. If we match randomly, we will definitely be able to match users who like each other. When everyone is successfully matched, they can safely chat socially here. Chatting every day can bring everyone closer and become closer, and many friends are using this social network. When you are on the platform, you definitely don’t want some of your friends or some friends in your mobile address book to find out. To avoid some embarrassing situations, you can use the method of blocking contacts here, and there are not many If you know how to block contacts, you can read these tutorials brought to you by the editor.

What is the status after TikTok is blocked by the other party? Can I still search for him after being blocked by him? What is the status after TikTok is blocked by the other party? Can I still search for him after being blocked by him? Mar 21, 2024 pm 04:26 PM

As one of the most popular short video platforms in the world, Douyin provides a stage for users to show themselves and share their lives. During use, users may encounter situations where they are blocked by the other party. So, what is the status after Douyin is blocked by the other party? Can I still search for him? This article will answer these questions for you. 1. What is the status after Douyin is blocked by the other party? When your Douyin account is blocked by the other party, you will not be able to view the other party's works, comments, likes, etc. on the Douyin platform. The other party also cannot view your works, comments, likes, etc. When both parties block each other, each other will completely disappear on the Douyin platform. 2. Can I still search for him after his TikTok is blocked? When your Douyin account is blocked by the other party, you enter the other party’s nickname in the Douyin search bar.

How to implement an online reservation system using WebSocket and JavaScript How to implement an online reservation system using WebSocket and JavaScript Dec 17, 2023 am 09:39 AM

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

See all articles