js 正则验证输入框只允许输入正实数和正整数和负整数

  1. <input onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')">  (正实数)
  2. <input onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"> (正整数)
  3.    <input type="text" onkeyup="this.value=this.value.replace(/[^(-)0-9]/g,'')" > (允许输入-号)
原文地址:https://www.cnblogs.com/guozhenyp/p/3499473.html