如果你对该文章中的内容有疑问/不解,可以点击此处链接提问
要注明问题和此文章链接地址 点击此处跳转
input 输入大于1的数(可以是整数或小数)oninput 和正则
<input type="number" oninput="this.value=this.value.replace(/[^1-9\.]/g,'');" //用的oninput方法和正则表达式,如果是只能输入大于0的整数或小数则改为(/[^0-9\.]/g,'') /
输入框只能输入正整数的最简实现
<input type='text' onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')">