In testing, using <input […] type="text" inputmode="numeric" pattern="[0-9]*"> mitigates these issues, with some minor drawbacks:
Between iOS 12.2 and 13.0, the numeric keypad with punctuation is displayed instead of the numeric keypad. Versions prior to 12.2 do not support inputmode, thus fallback to the pattern attribute, and continue to show the full numeric keypad. iOS 13 updates inputmode="numeric" to use the numeric keypad without punctuation.
Firefox, UC Browser (and older versions of other browsers) on android support neither inputmode nor pattern, and so will use the full alphanumeric keypad until those browsers introduce support for inputmode. (Note: neither Firefox nor UC browser on Android are listed in our own browser support matrix nor the service manual)
36degreesdeleted the date-input-type-text-inputmode-numeric branch 5 years ago
vanitabarrett
changed the title Update date input to type=text, inputmode=numeric Update date input to use `type=text` and `inputmode=numeric`3 years ago
Within the date input component the individual inputs look like this:
We set the input to
type="number"
so that Android browsers display a numeric keypad keyboard when the input is focussed.iOS uses the full alphanumeric keyboard for
type="number"
, so we addpattern="[0-9]*"
which triggers the numeric keypad there too. This is technically invalid HTML, as the pattern attribute only applies to inputs of typetext
,search
,url
,tel
andemail
, but is not known to cause any real-world issues.However, there are a number of known issues with inputs of
type="number"
– many of which were found in research and documented by @hannalaakso :(Bugs have been filed where appropriate)
In testing, using
<input […] type="text" inputmode="numeric" pattern="[0-9]*">
mitigates these issues, with some minor drawbacks:inputmode
, thus fallback to thepattern
attribute, and continue to show the full numeric keypad. iOS 13 updates inputmode="numeric" to use the numeric keypad without punctuation.inputmode
norpattern
, and so will use the full alphanumeric keypad until those browsers introduce support forinputmode
. (Note: neither Firefox nor UC browser on Android are listed in our own browser support matrix nor the service manual)Closes #1700