網(wǎng)站的搜索框輸入時(shí)如何屏蔽特殊字符?
< 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) " / >
我是有底線的
掃描二維碼手機(jī)查看該文章
文章引用:http://www.qingbaosc.com/news/webzhishi/1401.html




