时间:2021-07-01 10:21:17 帮助过:3人阅读
<script type="text/javascript">
var checkNo = function(e){
var keyCode = e.charCode ? e.which : e.keyCode;
if(keyCode == 8){
return true;
}
var realkey = String.fromCharCode(keyCode);
var reg = "\\d";
var regExp = new RegExp(reg);
return regExp.test(realkey);
}
</script>
2、限制输入最大字符串长度
代码如下:
//限制最大输入长度
var checkMaxL = function(length) {
var regC = /[^ -~]+/g;
var regE = /\D+/g;
var str = jQuery("#remark").val();
if (regC.test(str)){
jQuery("#remark").val(str.substring(0, length));
}
if(regE.test(str)){
jQuery("#remark").val(str.substring(0, length));
}
}