<!--只允许输入整数-->
<input type="text" name="verif" oninput="value=value.replace(/[^\d]/g,'')" >
<!--只允许输入整数和小数(小数只保留小数点后两位)-->
<input type="text" name="verif" oninput="value=value.match(/\d+\.?\d{0,2}/,'')" >
<!--限制只能输入正数、小数、负数-->
<input type="text" name="verif" oninput="this.value=this.value.replace(/[^\-?\d.]/g,'')"/>
input 只允许输入整数、小数(保留小数点后两位)
于 2022-08-10 09:25:39 首次发布