I am having a bit of a hard time figuring out how to only allow user to input numbers 0-9 in an <input type="number" />
as it also allwos other things like eE.+ -
etc..
Looked at regex solutions here on stack overflow and each one seems to have an issue i.e. if there are no numbers in an input you can type in any of unwanted characters, if you typed in a number you can't delete it completely as there needs to be at least 1 digit.
using keycodes introduces an issue as event.target.value
is not avaliable on key events, it seems to only be available in onchange
, however in this case e.which
is not avaliable to check key pressed.