输入框限制

249 阅读1分钟
正整数
<input type='text' oninput="value=value.replace(/^(0+)|[^\d]+/g,'')">
replace() 方法用于 在字符串中用一些字符 替换另一些字符。这里用空字符串 替换了//中的东西
正整数 和 两位小数
<input type="text" oninput="value=value.toString().match(/^\d+(?:\.\d{0,2})?/)">