3 ms·
Hmm. The author's problem is not with <input type=number> conceptually, which would be fine if properly supported by browsers, i.e. in the ideal world. In the
by IlliOnato 4y ago
Hmm. The author's problem is not with <input type=number> conceptually, which would be fine if properly supported by browsers, i.e. in the ideal world.
In the real world, however, the browsers apparently
a) don't prevent users from entering incorrect values
b) don't allow the developer to do anything about it programmatically, by preventing access to these incorrect values (always returning empty).
The author brings attention to this problem.
Now it's up to you as a developer to decide whether the benefits of using <input type=number> outweigh the costs, but the costs are real and you need to be aware of them.
- runarberg 4y agoIt is supported by all modern browsers. Even IE-11 supports valueAsNumber and the most important Constraint Validation API methods to deal with the problems the author mentions. If you want to deal with inconsistent (and possible eccentric) user input: Use input.valueAsNumber If you want to distinguish between empty and invalid inputs: Use input.validity.valid or input.validity.badInput If you want to programmatically deal with incorrect entries: Again use the constraint validation API.