1.只能输入英文

  <input type="text" onkeyup="value=value.replace(/[^a-zA-Z]/g,'')">


2.只能输入中文、英文、数字、@符号和.符号

  <input type="text" onkeyup="value=value.replace(/[^a-za-z0-9u4e00-u9fa5@.]/g,'')">


3.只能输入字母和汉字

  <input onkeyup="value=value.replace(/[d]/g,'') "onbeforepaste="clipboarddata.setdata('text',clipboarddata.getdata('text').replace(/[d]/g,''))" maxlength=10 name="numbers">



4.只能输入英文字母和数字,不能输入中文

  <input onkeyup="value=value.replace(/[^\w\/]/ig,'')"> 


5.只能输入英文字母和数字,不能输入中文

  <input onkeyup="value=value.replace(/[^\w\.\/]/ig,'')">



JS只能输入数字,数字和字母等的正则表达式_js



作者: ​​王磊的博客​