Your daily frequent11y newsletter, brought to you by @ChrisBAshton:
Are you sure that’s a number input?
Kilian Valkhof highlights how <input type="number">
is often used incorrectly, despite it being available in browsers for around 8 years now.
Number inputs display a ‘spinbox’ (up and down buttons) to make it easier to increment or decrement the input. This kind of indicates the type of thing this input type should be used for: non-identifying numbers.
Instead, a lot of sites use number inputs for things like 2FA codes, social security numbers and credit card numbers. These are identifiers, where if you’re off by just 1 digit it’s much the same as being off in ALL the digits. Having a spinbox for this provides no value.
If your input is a set of digits that is used to identify someone or something, it’s not a number
type, even if the input itself is entirely made of numbers. What you want in those cases is <input type="numeric">
.
Prefer longer newsletters? You can subscribe to week11y, fortnight11y or even month11y updates! Every newsletter gets the same content; it is your choice to have short, regular emails or longer, less frequent ones. Curated with ♥ by developer @ChrisBAshton.