On this page
You must include form validation in your form.
Form validation checks to make sure a user has filled out all required fields in the correct format.
Help users find the right information
Do what you can to help users avoid failing validation and getting an error message.
Set up your format validation so it’s as tolerant as possible of users entering information in different ways.
Be clear and concise
Focus on telling the user how to fix the problem rather than describing what’s gone wrong. The message must be in plain English, use positive language, and get to the point.
Be consistent
Use standard messages for different fields when you can.
Use the same message next for the field and in the error summary so they:
- look, sound, and mean the same
- make sense out of context
- reduce the cognitive effort needed to understand what has happened.
Use the full-sentence question label or field text label in the error message to provide context. For example, for the question 'What is your full name?' or the field label 'Full name' the error message for:
- no data - ‘Enter your full name'
- too many characters - 'Full name must be 150 characters or less'.
Be specific
General errors are not helpful to everyone. They do not make sense out of context.
Avoid messages like:
- ‘An error occurred’
- ‘Answer the question’
- ‘Select an option’
- ‘Fill in the field’
- ‘This field is required’.
Use messages like:
- 'Select at least one option for What are your favourite food groups?'
- 'Enter a date of birth'
- 'Enter a date of birth in the format dd/mm/yyyy'
Different errors need different messages. For example, text fields may be:
- empty
- too long
- too short
- using characters that are not allowed
- in the wrong format.
An error for a specific situation is more helpful. It will tell someone what has happened and how to fix it.
Use instructions and descriptions
Some errors work better as instructions and some work better as descriptions. For example:
‘Enter your given name’ is clearer, more direct, and more natural than ‘Given name must have an entry'
‘Enter a given name that is 35 characters or less’ is wordier, less direct, and less natural than ‘Givenname must be 35 characters or less'
‘Enter a date after 31 August 2017 for when you started the course' is wordier, less direct, and less natural than ‘Date you started the course must be after 31 August 2017’
Use both instructions and descriptions, but use them consistently. For example, use an instruction for empty fields like ‘Enter your name’, but a description like ‘Name must be 35 characters or less’ for entries that are too long.
Check for completeness, format, and sense
Validation should check for completeness, format, and sense:
Criteria | Test | Examples |
---|---|---|
Completeness | All required (mandatory) fields have data | Full name has at least 1 character. |
Format | All fields have data in the right format, including the number of characters |
Year has exactly 4 digits and no other characters. Note that missing digits should be detected via validation so the form-filler can make the appropriate correction, rather than automatically adding leading zeros. Number of digits in an Australian mobile phone number is exactly 10. |
Sense | Data is broadly sensible |
A parent's date of birth is not on or after their baby's date of birth. Age is not negative. Date of problem is after date of purchase. |
Data validation
All data entered will be validated at either the field level or page level.
All field and page summary error messages must show the same error message next to the field and in the error summary at the top of the page.
When the user clicks on the Next button or Submit button and mandatory fields are empty or don't meet format validations:
- the field is highlighted
- an error message is displayed below the field prompting the user to fix the error
- an error summary is displayed at the top of the page prompting the user to fix the error
Field and summary error messages
How to add error messages
Refer to Components.
Examples
Refer to the Data dictionary.
Technical guidance
Refer to the technical guidance provided by GOV.UK Design System for placement of Error messages, Error summaries, and Errors and validation.
System error messages
Types of service error messages that could be used are listed here.
There is a problem with the service
Sorry, there is a problem with the service
Try again later.
Contact [whoever it is] if you need assistance now.
Page not found
Page not found
If you typed the web address, check it is correct.
If you pasted the web address, check you copied the entire address.
If the web address is correct or you selected a link or button, contact [whoever it is] if you need assistance now.
Planned system maintenance
Example
Planned system maintenance - 3 August 2022
We will be [whatever it is] between 7:00 am to 9:00 am on 3 August 2022.
Contact [whoever it is] if you need assistance during this time.
Service unavailable
Sorry, the service is unavailable
You will be unable to use the service from 9:00 am on Monday 1 August 2022 to 4:00 pm on Tuesday 2 August 2022.
Contact [whoever it is] if you need assistance now.
High volumes of transactions
Example
We are currently experiencing high volumes of transactions and are unable to complete your request.
Try again later.
Contact [whoever it is] if you need assistance now.