I am trying to limit textbox input to numbers only, 0-9, without using regular expression. And, below is my code:
$("input[type='text']").on('keypress', function(e){
if(e.which>=48 && e.which<58){
return true;
}else{
return false;
}
})
<input type="text">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
My question is: "in this case, why only keypress prevents the input of special characters?"