textbox that accepts only numbers greater or equal to 0
Hello,
I'm looking for a way to make my textbox only accept numbers. It needs to accept all numbers greater or equal to 0 and any number of decimals. No negatives.
I found this online:
<input type="number" min="0" oninput="validity.valid||(value='');">
While this accomplishes almost everything I want, it has this odd glitch of not allowing any numbers in the decimal expansion except 0's. For example, if I type this:
8.0000
...it accepts it, but if I try to type:
8.00001
...it clears the field.
Try it:
https://jsfiddle.net/scrjhokk/
If anyone can help me fix this one glitch, this would be perfect for me. If not, then can anyone suggest an alternative way of doing this?