1、只能输入纯数字:

<input type='text' onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" />

2、只能输入数字和小数点

<input onkeyup="value=value.replace(/[^\d\.]/g,'')" onblur="value=value.replace(/[^\d\.]/g,'')"/>

3、只能输入数字和字母

<input onkeyup="value=value.replace(/[\W]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">

相关文章:

  • 2021-09-24
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2022-02-23
猜你喜欢
  • 2022-12-23
  • 2022-02-22
  • 2021-05-25
  • 2021-12-07
  • 2021-07-14
  • 2021-07-10
相关资源
相似解决方案