<!DOCTYPE html>
<html en">
<head>
<meta charset="UTF-8">
<title></title>
<script>
window.onload=function(){
var jNum = document.getElementById("number");
function clearNonumber(obj){
obj.value = obj.value.replace(/\D/g,"");
}
jNum.onfocus = function(){
clearNonumber(this);
};
jNum.onkeyup = function(){
clearNonumber(this);
};
jNum.onblur = function(){
clearNonumber(this);
}
};
</script>
</head>
<body>
<input type="text" id="number" placeholder="隻能輸入數字" value="">
</body>
</html>