Writing error messages
Error messages must explain to your user what went wrong and how to fix it.
Match up error messages to labels
Error messages should include language from the question or fieldset label. This helps match up the error message with the relevant form field.
Here are some examples of label and error message pairs.
Example 1:
- Label: ‘How many hours do you work a week?’
- Error message: ‘Enter how many hours you work a week’
Example 2:
- Label: ‘Address line 1’
- Error message: ‘Enter address line 1, typically the building and street’
Be clear and concise
The message must be in plain English, use positive language and get to the point.
Do not use:
- technical jargon like ‘form post error’, ‘unspecified error’ and ‘error 0x0000000643’
- words like ‘forbidden’, ‘illegal’, ‘you forgot’ and ‘prohibited’
- ‘please’ because it implies a choice
- ‘sorry’ because it does not help fix the problem
- ‘valid’ and ‘invalid’ because they do not add anything to the message
- humorous, informal language like ‘oops’
Do not include the word ‘field’ in your error message text as this can become repetitive and is not helpful to users.
Make sure your error message does not repeat guidance in your hint text. For example, if you provide an example like ‘REF 012345’ in the hint text for a reference number, do not repeat ‘REF 012345’ in the error message.
Above all, aim for clarity. Read the message out loud to check if it sounds like something you would say.
Be specific
General errors are not helpful to everyone. They do not make sense out of context. Do not use messages like:
- ‘An error occurred’
- ‘Answer the question’
- ‘Select an option’
- ‘Fill in the field’
- ‘This field is required’
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.
There are specific error messages for specific error states on the pages for:
Use instructions and descriptions
Some errors work better as instructions and some work better as descriptions.
Error example using instructions
‘Enter your first name’ is clearer, more direct and natural than ‘First name must have an entry’.
Error examples using description
‘First name must be 35 characters or fewer’ is more concise, direct and natural than ‘Enter a first name that is 35 characters or fewer’.
‘Date you started the course must be after 31 August 2017’ is more concise, direct and natural than ‘Enter a date after 31 August 2017 for when you started the course’.
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 fewer’ for entries that are too long.
Our guidance
Our guidance is based on GOV.UK advice on how to write error messages.
Have a question, suggestion or feedback?
The Improving User Experience cluster manages the design system.
If you work in Parliament, contact us on the #design-system Slack channel.