input el-input 只能输入正整数验证

字母e在js中属于数字,所以一般的正则匹配 \d 是拦不住字母e 的

正确写法为:

onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"

猜你喜欢

转载自www.cnblogs.com/fmixue/p/10957038.html