Simplest solution is parseInt() .
<input type="number" onkeyup="this.value = parseInt(this.value); this.paste(this.onkeyup);"/>
ParseInt() returns blank(NaN) for E, e, +, - and anything which is not a number.
Use onkeyup
and keydown
according to your convenience with paste
event. For me onkeyup
works best,. This works with copy-paste as well