UX
Number input fields are more complex than they seem.
- Do not use
type="number"
type="number"
is intended for integers and includes features we don’t want (like stepper/scroll functionality) that is a nuisance to everyone.- Phone, credit card, pin etc. are not integers
- Older versions of NVDA don’t support
type="number"
- Screen readers do not call a
type="number"
input a number input, they call it:- Spinner
- Spin button
- Stepper
- Incrementable edit text number field
Use type="text"
for number inputs
Use type=text
with inputmode="numeric"
with an input pattern and JS to filter out non-numeric characters.
Annotations for number inputs
type=text inputmode="numeric"
- Ensures maximum support and opens the numeric keypad on mobile devices
The pin number will expire after 1 hour
Annotations for telephone input
type="tel"
- Ensures maximum support and opens the numeric keypad on mobile devices
We’ll never sell or share your information