input只能输入数字
<input type="text" oninput = "value=value.replace(/[^\d]/g,'')" />
input限制长度(字符数)
<input type="text" οninput="if(value.length>11)value=value.slice(0,11)" />
限制大小(最大值30、最小值0)
<input type="text" οninput="if(value>30)value=30;if(value<0)value=0" />
input框为text时 oninput事件才会生效,为number时当用户手动输入数字时并不能生效
文章来源于:https://blog.csdn.net/sinat_21843047/article/details/88723236