currently I have the following code
it comes out to something like this
I cannot find the perfect solution as some work for inputting but not for copy&paste, some are the other way around. This solution works for me. It prevents from negative number, typing "e", copy&paste "e" text.
create a function.
add these properties to input. this two prevent from copy&paste non-number text, including "e". you need to have both together to take effect.
If you are using Vue you can refer this answer here. I have extracted it to a mixin which can be reused.