当前位置: 代码迷 >> Eclipse >> jsp中onbeforepaste有关问题
  详细解决方案

jsp中onbeforepaste有关问题

热度:95   发布时间:2016-04-23 00:17:37.0
jsp中onbeforepaste问题

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和火狐测试都可以了,没有报错
  相关解决方案