<input type="text" class="vatinput" placeholder="请输入验证码">
$('.vatinput').on('keyup',function(){
var value=$(this).val();
$(this).val(value.replace(/[^\d$]{0,7}/g,''));
})
限制不住长度
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
为什么不直接用maxlength限制呢,或者说直接substring截取呢~ 非要用正则吗?