(转)输入时屏蔽特殊字符
<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)" />
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)" />