<input type="text" class="vatinput" placeholder="请输入验证码">
$('.vatinput').on('keyup',function(){
var value=$(this).val();
$(this).val(value.replace(/[^\d$]{0,7}/g,''));
})
限制不住长度
为什么不直接用maxlength限制呢,或者说直接substring截取呢~ 非要用正则吗?
<input type="text" class="vatinput" placeholder="请输入验证码" maxlength='7'>
input本身不就能限制长度么?