Skip to content

Commit

Permalink
Use inputmode="numeric" and pattern for relevant fields
Browse files Browse the repository at this point in the history
We've done some investigation to show that now in certain
scenarios this is the best way of collecting numeric data from users. We have a
bunch of changes to make to roll this out in GOV.UK Frontend:
alphagov/govuk-frontend#1449 (comment)
After that, we can set this in the input component itself instead of using the
`attributes` object.

Following our above investigation, GOV.UK Pay introduced this change for
collecting credit card details:
alphagov/pay-frontend#921 They haven't seen
any issues so we are sufficiently confident to make the same change
in the Design System.

This is only applied to sort code and account number as the other data collected
is alphanumeric.

Tested on iOS 12 and 13, Android 9 and 8.
  • Loading branch information
hannalaakso committed Oct 17, 2019
1 parent 632b856 commit 9bbc2f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/patterns/bank-details/default/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ layout: layout-example.njk
id: "sort-code",
name: "sort-code",
attributes: {
spellcheck: "false"
spellcheck: "false",
inputmode: "numeric",
pattern: "[0-9]*"
}
}) }}

Expand All @@ -45,7 +47,9 @@ layout: layout-example.njk
id: "account-number",
name: "account-number",
attributes: {
spellcheck: "false"
spellcheck: "false",
inputmode: "numeric",
pattern: "[0-9]*"
}
}) }}

Expand Down
4 changes: 3 additions & 1 deletion src/patterns/bank-details/error/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ layout: layout-example.njk
id: "sort-code",
name: "sort-code",
attributes: {
spellcheck: "false"
spellcheck: "false",
inputmode: "numeric",
pattern: "[0-9]*"
},
errorMessage: {
text: "Enter a valid sort code like 309430"
Expand Down

0 comments on commit 9bbc2f6

Please sign in to comment.