用正则表达式限制只能输入中文:onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))"

用正则表达式限制只能输入全角字符: onkeyup="value=value.replace(/[^\uFF00-\uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\uFF00-\uFFFF]/g,''))"

用正则表达式限制只能输入数字:onkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"

用正则表达式限制只能输入数字和英文:onkeyup="value=value.replace(/[\W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"

 

转自:http://www.cnblogs.com/Ken-Cai/archive/2008/06/30/1232330.html

相关文章:

  • 2018-09-20
  • 2021-09-18
  • 2019-07-14
  • 2021-05-17
  • 2022-02-04
  • 2022-01-05
  • 2021-10-27
猜你喜欢
  • 2021-08-16
  • 2022-01-15
  • 2022-01-27
  • 2021-05-22
  • 2021-12-02
  • 2021-09-11
  • 2020-05-27
相关资源
相似解决方案