js怎么判断字符串中只有数字和小数点

1、keyCode的使用

<input type ='text' onkeypress = "return check()">

<script>
function check(){
  var _iKeyCode = window.event.keyCode;

    if ((_iKeyCode < 48  || _iKeyCode > 57) && _iKeyCode!=46)
      window.event.returnValue = false;
    return true;

}
</script>

2、使用正则表达式

……

相关文章:

  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-02-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案