<input
onkeypress="return /[0-9a-zA-Z\u4E00-\u9FA5]/g.test(String.fromCharCode(event.keyCode))"
onpaste="return !clipboardData.getData('text').match(/[0-9a-zA-Z\u4E00-\u9FA5]/)"
ondragenter="return false"
>
onkeypress="return /[0-9a-zA-Z\u4E00-\u9FA5]/g.test(String.fromCharCode(event.keyCode))"
onpaste="return !clipboardData.getData('text').match(/[0-9a-zA-Z\u4E00-\u9FA5]/)"
ondragenter="return false"
>
hrong(黄蓉): 你好,谢谢你的指教。
不过 〈〉!〉〈·¥》这些符号还是能够输入,这些都是中文全角字符。怎么禁止掉?还有我想让用户可以输入 _ 也就是英文的下划线。谢谢!
onkeypress="return /[\w\u4E00-\u9FA5]/g.test(String.fromCharCode(event.keyCode))"
onpaste="return !/[^\w\u4E00-\u9FA5]/g.test(clipboardData.getData('text'))"
ondragenter="return false"
>
现在可以输入下划线了, 不过 〈〉!〉〈·¥》我这边测试不能输入呀!
<input name=txt
onkeydown="oldValue=value; setTimeout('mm()')"
onpaste="return !/[^\w\u4E00-\u9FA5]/g.test(clipboardData.getData('text'))"
ondragenter="return false"
></form><SCRIPT LANGUAGE="JavaScript">
var oldValue;
function mm()
{
with(document.form1.txt)
if(/[^\w\u4E00-\u9FA5]/g.test(value)) value = oldValue;
}
</SCRIPT>