麟の随笔

  • 游戏
  • 影视
  • Tech
  1. 首页
  2. 科技
  3. 前端
  4. 正文

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

2021年9月4日 1038点热度 0人点赞 0条评论

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,'')">
标签: 暂无
最后更新:2021年9月4日

晓虎

必须有人浴血奋战,世上才有自由可言!

点赞
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2024 kirinz.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

闽ICP备19013981号