jsp中有一个text文本,限制只能输入中文,当输入其他内容时,文本框不显示出来。
<input type="text" value="请输入您的姓名" name="name" id="name" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))">
onbeforepaste出现警告 -------Undefined attribute name (onbeforepaste).
------解决思路----------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<input type="text" value="请输入您的姓名" name="name" id="name" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))">
</body>
</html>
IE8和火狐测试都可以了,没有报错