当前位置:网站首页>js过滤/替换敏感字符
js过滤/替换敏感字符
2022-07-23 11:45:00 【爱笑的陈sir】
输入内容的文本框
<input type="text" id="ip1">
替换按钮
<button id="bt1">替换</button>

小案列需求:
//替换 不健康 ***
//点击替换按钮时,获取用户输入的内容,如果获取内容中包含暴力,将其替换为 ***
// 点击事件 onclick
var bt1=document.getElementById("bt1")
bt1.onclick=function(){
var ip1=document.getElementById("ip1")
var content=ip1.value
//将content中敏感字符 替换为 ***
//将字符串中指定的字符串替换
控制台console.log(content)输出

content=content.replace("不健康","***")
// console.log(content)
ip1.value=content
}

以上到这里就结束,但未没有完全结束。
思考题:
如上图所示:假如文本框中输入两个/多个敏感字符(不健康),点击替换按钮只会替换第一个不健康为***,如果出现第二个/多个不健康点击替换按钮的结果是zsdcaasc***,这么一来,问题就出现了,我们该如何替换所有指定的字符串呢? 当然这个问题留给大家思考。
边栏推荐
猜你喜欢

对C语言最基本的代码解释
![Php:filter pseudo protocol [bsidescf 2020]had a bad day](/img/ad/1e23fadb3f1ce36b297aaa767d9099.png)
Php:filter pseudo protocol [bsidescf 2020]had a bad day

One minute rule for sequential disk access

超详细MP4格式分析
![[operation and maintenance] SSH tunneling relies on the 22 port of SSH to realize the interface service of accessing the remote server](/img/4a/7156470e8d96c7709001bac88e872c.png)
[operation and maintenance] SSH tunneling relies on the 22 port of SSH to realize the interface service of accessing the remote server

C语言学习笔记

day14函数模块

基于Matlab的SSB信号调制和解调(内附源码)

自定义封装弹出框(带进度条)

C language learning notes
随机推荐
Without Huawei, Qualcomm will raise prices at will, and domestic mobile phones that lack core technology can only be slaughtered
946. 验证栈序列 ●● & 剑指 Offer 31. 栈的压入、弹出序列 ●●
Google Earth Engine——影像统计过程中出现的空值问题
Redis的过期策略以及内存淘汰机制,Key过期了为什么没释放内存
Suffix expression (summer vacation daily question 4)
(Zset) how is the underlying layer of redis stored with a hop table
虚拟主播、偶像代言产品出问题谁负责?律师解析
CS5363,CS5350,CS5328几款太阳能板电池充电管理IC的功能特性与参数对比
手机使用多了可能会丢掉工作
Alamofire 框架封装与使用
C语言书写规范
bug修改
Fake XML cookbook of XML xxE vulnerability
Bug modification
【攻防世界WEB】难度三星9分入门题(上):simple_js、mfw
【运维】ssh tunneling 依靠ssh的22端口实现访问远程服务器的接口服务
後綴錶達式(暑假每日一題 4)
day1
Kirin V10 source code compilation qtcreater4.0.3 record
[attack and defense world web] difficulty Samsung 9 points introductory question (Part 2): shrink, lottery
