更改价值输入onclick女巫settimeout
单击按钮时,如何删除特殊符号(r $),或者如果它存在,则只需删除?
setTimeout(function clean() {
var input = document.getElementById('value')
input.value = input.value.replace(/[!$(){}[\]:;R<+?\\>]/g,'')
},3000)
我希望在单击按钮时,它也将删除
我到目前为止的
符号r $
setTimeout(function clean() {
var input = document.getElementById('value')
onclick = input.value = input.value.replace(/[!$(){}[\]:;R<+?\\>]/g,'')
}, 2000)
<input id="value" name="item_valor" value="R$ 14,99" >
remover simbolo pagseguro
<br>
<button class="" onclick="clean()">clean</button>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需使用 方法,然后
string.trim()
方法,以确保没有留下前导或落后空间。Just use the
String.replace()
method and then theString.trim()
method to ensure there are no leading or trailing spaces left behind..您的删除特殊符号的正则是正确的
Settimeout的唯一错误&amp;功能声明错误。
我已经解决了该代码错误。
下图下方可以工作,但是在函数清洁()中,由于Settimeout功能,它将等待1000ms。
Your regex for removing the special symbol is right,
only error was of setTimeout & function declaration error.
I have fixed that code error.
Below snippet will work, but in function clean() it will wait for 1000ms because of setTimeout function.