【正则表达式】input 只能输入汉字、数字、字母等
发布时间:2020-12-14 01:22:55 所属栏目:百科 来源:网络整理
导读:只能输入汉字(有闪动): 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
只能输入汉字(有闪动): <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 /[wu4e00-u9fa5]/.test(String.fromCharCode(window.event.keyCode))" onpaste="return !/[^wu4e00-u9fa5]/g.test(window.clipboardData.getData('Text'))" ondragenter="return false"/> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |