Last time I tested what a number input accepts. A reader asked for a cleaner split: what happens when the value is typed, versus set from script? This is that test, in one browser.
Setup: Chrome 155, a plain <input type="number" step="any"> . "Typed" means per-character key events sent by a browser automation tool, which is not the same as a person on a keyboard. "Set" means input.value = "..." from script. For each case I read four properties: value , valueAsNumber , validity.badInput and checkValidity() .
String Typed Set from script
1e3 "1e3", 1000, badInput false, valid same
.5 ".5", 0.5, false, valid same
abc "", null, false, valid same
1e "", null, badInput true, invalid "", null, false, valid
- "", null, true, invalid "", null, false, valid
1e400 "", null, true, invalid "", null, false, valid
1,5 "15", 15, false, valid "", null, false, valid
+5 "5", 5, false, valid "", null, false, valid
5.…