用正则表达式限制只能输入中文: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

相关文章:

  • 2021-12-13
  • 2021-11-03
  • 2021-05-17
  • 2022-02-04
  • 2021-10-27
  • 2021-12-08
  • 2022-01-05
  • 2022-01-16
猜你喜欢
  • 2021-08-16
  • 2022-01-15
  • 2022-01-27
  • 2021-12-02
  • 2021-05-22
  • 2021-12-03
  • 2022-01-14
相关资源
相似解决方案