【正则表达式】input 只能输入汉字、数字、字母等

只能输入汉字(有闪动):

<input type="text" id="searchStr" name="searchStr" value="请输入姓名"
			onkeyup="this.value=this.value.replace(/[^\u4E00-\u9FA5]/g,'')"  />

只能输入数字(有闪动):

<input type="text" id="searchStr" name="searchStr" value="请输入身份证号码"
			onkeyup="this.value=this.value.replace(/[^\d]/g,'')"  />

只能输入汉字、字母和数字(无闪动):

			<input type="text" id="searchStr" name="searchStr" value="请输入姓名或身份证号"
			onkeypress="return /[\w\u4e00-\u9fa5]/.test(String.fromCharCode(window.event.keyCode))"   
      		onpaste="return !/[^\w\u4e00-\u9fa5]/g.test(window.clipboardData.getData('Text'))"   
      		ondragenter="return false"/>

相关文章

正则替换html代码中img标签的src值在开发富文本信息在移动端...
正则表达式
AWK是一种处理文本文件的语言,是一个强大的文件分析工具。它...
正则表达式是特殊的字符序列,利用事先定义好的特定字符以及...
Python界一名小学生,热心分享编程学习。
收集整理每周优质开发者内容,包括、、等方面。每周五定期发...