js按键输入过滤 - javascript -

js按键输入过滤

时间:2010-01-27 14:22:34   来源:   评论:加载中...   点击:加载中...
+文本框只允许输入英文、数字和下划线:<input onkeypress="return !String.fromCharCode(event.keyCode).match(/W/)" onpaste="return...

+文本框只允许输入英文、数字和下划线:

<input onkeypress="return !String.fromCharCode(event.keyCode).match(/W/)" onpaste="return !clipboardData.getData('text').match(/W/)" style="ime-mode:Disabled" ondragenter="return false">

粘贴前过滤字符

<input name="lc" id="lc" value="" size="2" maxlength="3" type="text" class="txt2" onkeyup="value=value.replace(/[^d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,''))" />



相关热词搜索:

 
上一篇:正则表达式全集
下一篇:javascript document对象属性
收藏 将此文推荐给朋友
分享到: