Experimental
This pattern is currently experimental because more research is needed to validate it.
Telephone numbers
This pattern is currently experimental because more research is needed to validate it.
<div class="govuk-form-group">
<label class="govuk-label" for="telephone-number">
UK telephone number
</label>
<input class="govuk-input govuk-input--width-20" id="telephone-number" name="telephone-number" type="tel" autocomplete="tel"></div>
{% from "govuk/components/input/macro.njk" import govukInput %}
{{ govukInput({
label: {
text: "UK telephone number"
},
id: "telephone-number",
name: "telephone-number",
type: "tel",
autocomplete: "tel",
classes: "govuk-input--width-20"
}) }}
When to use this pattern
Only collect telephone numbers from people if you genuinely need them. Not everyone has or can use a telephone, so make sure you give users a choice about how they can be contacted.
How it works
Allow different formats
Users should be allowed to enter telephone numbers in whatever format is familiar to them. You should allow for additional spaces, hyphens, brackets and dashes, and be able to accommodate country and area codes.
Validate telephone numbers
You should validate telephone numbers so you can let users know if they have entered one incorrectly. Google’s libphonenumber library can validate telephone numbers from most countries.
Use the autocomplete attribute
Use the autocomplete
attribute on telephone number inputs. This lets browsers autofill the information on a user’s behalf if they’ve entered it previously.
To do this, set the autocomplete
attribute to tel
, as shown in the HTML and Nunjucks tabs in the examples on this page.
If you are working in production you’ll need to do this to meet WCAG 2.1 Level AA.
You will not normally need to use the autocomplete
attribute in prototypes, as users will not generally be using their own devices.
Error messages
Error messages should be styled like this:
<div class="govuk-form-group govuk-form-group--error">
<label class="govuk-label" for="telephone-number">
UK telephone number
</label>
<span id="telephone-number-error" class="govuk-error-message">
<span class="govuk-visually-hidden">Error:</span> Enter a UK telephone number
</span>
<input class="govuk-input govuk-input--width-20 govuk-input--error" id="telephone-number" name="telephone-number" type="tel" aria-describedby="telephone-number-error" autocomplete="tel"></div>
{% from "govuk/components/input/macro.njk" import govukInput %}
{{ govukInput({
label: {
text: "UK telephone number"
},
errorMessage: {
text: "Enter a UK telephone number"
},
id: "telephone-number",
name: "telephone-number",
type: "tel",
autocomplete: "tel",
classes: "govuk-input--width-20"
}) }}
Make sure errors follow the guidance in error message and have specific error messages for specific error states.
If the telephone number is not in the correct format and there is no example
Say ‘Enter a telephone number, like 01632 960 001, 07700 900 982 or +44 0808 157 0192’.
If the telephone number is not in the correct format and there is an example
Say ‘Enter a telephone number in the correct format’.
Make it clear what type of telephone number you need
Use the form label or hint text to tell users if you specifically need a UK, international or mobile telephone number.
<div class="govuk-form-group">
<label class="govuk-label" for="telephone-number">
Telephone number
</label>
<div id="telephone-number-hint" class="govuk-hint">
For international numbers include the country code
</div>
<input class="govuk-input govuk-input--width-20" id="telephone-number" name="telephone-number" type="tel" aria-describedby="telephone-number-hint" autocomplete="tel">
</div>
{% from "govuk/components/input/macro.njk" import govukInput %}
{{ govukInput({
label: {
text: "Telephone number"
},
hint: {
text: "For international numbers include the country code"
},
id: "telephone-number",
name: "telephone-number",
type: "tel",
autocomplete: "tel",
classes: "govuk-input--width-20"
}) }}
Using example telephone numbers
If you wish to include an example telephone number (in hint text for example), Ofcom maintains a list of numbers that are reserved for use in media. These are:
- UK non-geographic: 01632 960000 to 960999
- UK London: 020 7946 0000 to 7946 0999
- UK mobile: 07700 900000 to 900999
Explain why you need a telephone number
Tell users why you might contact them and when.
Do not display telephone numbers as links on devices that cannot make calls
It’s possible to mark up telephone numbers as links, like this:
<a href="tel:+442079476330">020 7947 6330</a>
However, doing this will style telephone numbers as links, which is confusing on devices that do not support telephone calls, like most desktop machines.
It’s also not necessary - most modern mobile browsers automatically detect telephone numbers and display them as links anyway.
If you do need to mark up your telephone number as links, for example, to support a device that cannot automatically detect them, make sure they do not display as links on devices that cannot make calls.
Write telephone numbers in the GOV.UK style
See the GOV.UK style for writing telephone numbers.
Avoid input masking
Avoid input masking because it makes it harder for users to:
- type a number in their preferred way
- transcribe a number from another place and check that they’ve got it right
Avoid reformatting telephone numbers
The GOV.UK Notify team have observed some users becoming confused when presented with a reformatted version of a telephone number that they provided, for example, with the +44 country code added.
Research on this pattern
More research is needed on the best way to handle:
- international numbers
- extensions
- SMS shortcodes
Help improve this page
To help make sure that this page is useful, relevant and up to date, you can:
- share your research or feedback on GitHub
- propose a change – read more about how to propose changes in GitHub
Need help?
If you’ve got a question about the GOV.UK Design System, contact the team.