Error messages - smbc-digital/patterns GitHub Wiki

Error messages

Use an error message to identify when the user has not provided the information in the format you are expecting. To help the user, you should show an error message that allows them to fix the problem.

Error messages should:

  • directly include language from the question or fieldset label
  • describe what has happened and tell the user how to fix it
  • use both instructions and descriptions, but use them consistently
  • be consistent and specific

Enter

Starting an error message with 'Enter' tends to work for most text fields and textareas. People can choose whether to use a custom error message when designing/building the form, if they don't provide a custom error message then a default error message starting with the word 'Enter' and using the default fieldset label will automatically be applied.

Examples:

Enter your first name Enter your last name Enter your email address Enter your phone number Enter your date of birth Enter further location details


Select

If the question has a yes or no answer then we can use 'Select yes...'

Examples:

Select yes if this is your home address Select yes if you receive benefits Select yes if the child has any known siblings of school age Select yes if you would like to pre-order gift bag

If there are multiple options to choose from and the question is specific then we can use what is in the question to form the error message.

Examples:

Question: What type of pest are you requesting treatment for? Error message: Select the type of pest you're requesting treatment for Question: What benefit do you receive? Error message: Select the benefit that you receive Question: Which problem are you reporting? Error message: Select the problem you're reporting Question: Which type of licence do you currently hold for the vehicle? Error message: Select which type of licence you currently hold for the vehicle

If the question isn't specific enough to group the answers such as 'Select a country' then a list of countries. Only then would we make an exception to allow 'Select an option'. This is not best practice and should only be used if necessary.


Note: We don't always use questions, in these scenarios it can be tricky to write an error message that fits using 'Enter'. In these scenarios you can do the following:

Example: Tell us where the pest is located in the property Error message: Tell us where the pest is located in the property


For more examples of error messages visit GOV.UK Design System - Error message. Scroll down to the bottom of the page to find the list of error message templates.

Use the examples in the GOV.UK Design System, but if you need further help with writing an error message where you can't find an example, then speak to someone in the Content and UX team for help.