限制文本框只能输入正数,负数,小数
onkeyup="value=value.replace(/[^\-?\d.]/g,'')"
限制文本框只能输入正数,小数
onkeyup="value=value.replace(/[^\d.]/g,'')"
输入框只能输入正整数,输入同时禁止了以0开始的数字输入,防止被转化为其他进制的数值。
<!-- 不能输入零时-->
<input type='text' οninput="value=value.replace(/^(0+)|[^\d]+/g,'')">
<!-- 能输入零时-->
<input type='text' οninput="value=value.replace(/^0+(\d)|[^\d]+/g,'')">
完整格式
<input id="c-low_rent_price" data-rule="required" placeholder="底价" class="form-control col-d-in col-d-input-center" name="row[low_rent_price]" type="text" onkeyup="value=value.replace(/[^\d.]/g,'')" value="">