# Error messages and validation

Error messages name the problem and show how and where to fix it.

Every field needs a unique error message.

**Wait to validate.** Only show error messages after a user has exited the field.

More: [Writing clearer error messages](https://uxdesign.cc/writing-clearer-error-messages-d57d6f388140)

### **Validation**

If an answer makes a user ineligible for a program or is not accepted, the form should:

1. Stop them from filling out the rest of the form
2. Explain why they cannot proceed
3. Give them another place to go

For example, a user may need to be more than 18 to register for a service. Their date of birth makes them ineligible. After they input their DOB, the error message reads:

CityTestSF cannot accept people who are under 18 years old. Call a doctor to find another way to get tested.<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sfdigitalservices.gitbook.io/style-guide/how-to-write-forms/error-messages-and-validation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
