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>
posted on 2015-12-09 00:25  菜鸟阿文  阅读(201)  评论(0编辑  收藏  举报