限制输入框只能输入数字(使用正则) let reg=/[/D]/g; input.oninput=function(){ this.value=this.value.replace(reg,''); } /D: 匹配数字 /d: 匹配除数字以外的任何