网站的搜索框输入时如何屏蔽特殊字符?
< script language = " javascript " type = " text/javascript " >
var arr = new Array();arr[ 0 ] = / [`~!@#$%^&*
+][}{';:" / ., > < ]s | = - ? ] / g;
arr[ 1 ] = / [^d] / g;
// 屏蔽输入的特殊字符
function filtecharacter(obj, index) {
obj.value = obj.value.replace(arr[index], "" );
}
< / script>
< input type = " text " name = " name " maxlength = " 19 " class = " text " onkeyup = " filtecharacter(this,0) " / >
arr[ 1 ] = / [^d] / g;
// 屏蔽输入的特殊字符
function filtecharacter(obj, index) {
obj.value = obj.value.replace(arr[index], "" );
}
< / script>
< input type = " text " name = " name " maxlength = " 19 " class = " text " onkeyup = " filtecharacter(this,0) " / >
扫描二维码手机查看该文章
文章引用:https://www.qinghuahulian.com/news/webzhishi/1401.html