방법.1



<script type="text/javascript">
function onlyNumber(event){
event = event || window.event;
var keyID = (event.which) ? event.which : event.keyCode;
if ( (keyID >= 48 && keyID <= 57) || (keyID >= 96 && keyID <= 105) || keyID == 8 || keyID == 46 || keyID == 37 || keyID == 39 )
return;
else
return false;
}
function removeChar(event) {
event = event || window.event;
var keyID = (event.which) ? event.which : event.keyCode;
if ( keyID == 8 || keyID == 46 || keyID == 37 || keyID == 39 )
return;
else
event.target.value = event.target.value.replace(/[^0-9]/g, "");
}
</script>

<input type="number" pattern="[0-9]*" placeholder="숫자만 입력" onkeydown="return onlyNumber(event)" onkeyup="removeChar(event)" style="ime-mode:disabled;">





방법.2



<script>
function onlyNumber2(obj) {
obj.value = obj.value.replace(/\D/g, '');
}
</script>

<input type="number" pattern="[0-9]*" placeholder="숫자만 입력" onkeyup="onlyNumber2(this)" style="ime-mode:disabled;">