Non-numeric input is prohibited, but Sogou Input can still enter the letter e in Chinese.

< input type="number" onkeypress="return (/ [d] / .test (String.fromCharCode (event.keyCode)"/ >
this expression can still enter the letter e in Chrome browser and Sogou Input Chinese input state. The letter e may have a special value in mathematics. How to disable the input of e?

Mar.12,2021

[0,9] numbers
[0,9\.] Decimal
[0,9\.\ -] Decimal negative


The

keypress event is not compatible and it is not recommended to listen to this event.
clipboard.png

you can listen to the input event, and then use the rule to determine whether the string is legal:

  https://codepen.io/CodingMonk.

Menu