<input type="text" value="" name="test" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " maxlength="6"> 转载于:https://blog.51cto.com/skyseas/1188028