Skip to content

Commit

Permalink
PP-5366 - use inputmode and pattern attribute on numeric fields
Browse files Browse the repository at this point in the history
The Design System team have done some accessibility testing on `input
type="number"` and deemed them problematic. They have suggested using

`input type="text" inputmode="numeric" pattern="[0-9]*"`

instead as documented here alphagov/govuk-frontend#1449
  • Loading branch information
jonheslop committed Jun 25, 2019
1 parent f2de5e5 commit e9917ba
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/views/dashboard/demo-payment/edit-amount.njk
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
autofocus
data-non-numeric
type="text"
inputmode="numeric"
pattern="[0-9]*"
id="payment-amount"
value="{{ paymentAmount | penceToPounds }}"
data-validate="required currency belowMaxAmount"
Expand Down
4 changes: 3 additions & 1 deletion app/views/login/otp-login.njk
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
type: "text",
attributes: {
"autofocus": "true",
"autocomplete": "off"
"autocomplete": "off",
"inputmode": "numeric",
"pattern": "[0-9]*"
}
})
}}
Expand Down
2 changes: 2 additions & 0 deletions app/views/payment-links/amount.njk
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
autofocus
data-non-numeric
type="text"
inputmode="numeric"
pattern="[0-9]*"
id="payment-amount"
value="{{ paymentLinkAmount | penceToPounds if paymentLinkAmount else '' }}"
data-trim
Expand Down
2 changes: 2 additions & 0 deletions app/views/payment-links/edit-amount.njk
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
autofocus
data-non-numeric
type="text"
inputmode="numeric"
pattern="[0-9]*"
id="payment-amount"
value="{{ product.price | penceToPounds if product.price else '' }}"
data-trim
Expand Down
8 changes: 6 additions & 2 deletions app/views/stripe-setup/bank-details/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
errorMessage: accountNumberError,
attributes: {
"data-validate": "required accountNumber",
"autocomplete": "off"
"autocomplete": "off",
"inputmode": "numeric",
"pattern": "[0-9]*"
}
}) }}

Expand All @@ -77,7 +79,9 @@
errorMessage: sortCodeError,
attributes: {
"data-validate": "required sortCode",
"autocomplete": "off"
"autocomplete": "off",
"inputmode": "numeric",
"pattern": "[0-9]*"
}
}) }}

Expand Down
5 changes: 5 additions & 0 deletions app/views/transactions/filter.njk
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
hint: {
text: 'Last 4 digits of associated card',
classes: 'govuk-!-font-size-14'
},
attributes: {
"autocomplete": "off",
"inputmode": "numeric",
"pattern": "[0-9]*"
}
})
}}
Expand Down
4 changes: 3 additions & 1 deletion app/views/twoFactorAuth/configure.njk
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
attributes: {
"data-validate": "required",
"autocomplete": "off",
"autofocus": true
"autofocus": true,
"inputmode": "numeric",
"pattern": "[0-9]*"
}
})
}}
Expand Down

0 comments on commit e9917ba

Please sign in to comment.