keycode
<input type="number" id="myid"/>
<script>
var parentValue;
var myid=document.getElementById("myid");
myid.onkeyup=function(e){
var keyCode=e.keyCode;
var value=this.value;
if(!value){
value=(keyCode==8)?"":parentValue;
}else{
//正则
}
parentValue=value;
myid.value=value;
alert(this.value);
}
</script>