I guess they are treated as e for exponential, +,- for negative and positive integers. One of things we can further verify if fwChange is observed when e,+,- is typed by the user in order to event.preventDefault();
Seems like even that doens’t seem to work because hanlder listening to fwChange doesn’t seem to emit events for e,+,- (Needs to be re-verified.)
Good point @Saif, those characters should be valid. I completely missed it. 2e10, -2e4, -10e+2 are all valid number representations.
fwChange gets triggered with an empty value in the event payload’s target.value. Also, the value property of the DOM element goes empty. So in this case, this happens when the number is invalid. For example:
2e is an invalid number, so, fwChange triggers with target.value as an empty string.
2e10 is a valid number, so fwChange triggers with target.value as a number string.
The type of the value is always string. The correct way to parse this will then be to use parseFloat(event.target.value).
const inputNum = document.getElementById("input-num");
inputNum.addEventListener("fwChange", function (evt) {
// String representation. Will be empty string when invalid number is input
console.log(evt.target.value);
// Parsed number. Will be NaN when invalid number is input
console.log(parseFloat(evt.target.value));
});