jQuery实现input输入框内容限制只能输入和粘贴数字整数
$(function(){ $("[name='price_input'],[name='price']").on('input propertychange afterpaste',function(){ let v = this.value.replace(/[^0-9]/g,''); this.value = v == '' ? 0 : v; }); });
黄金分割
jQuery实现input输入框内容限制只能输入和粘贴数字整数
$(function(){ $("[name='price_input'],[name='price']").on('input propertychange afterpaste',function(){ let v = this.value.replace(/[^0-9]/g,''); this.value = v == '' ? 0 : v; }); });