Skip to content

Latest commit

 

History

History
40 lines (25 loc) · 1.37 KB

error-message.md

File metadata and controls

40 lines (25 loc) · 1.37 KB

Error message

GDS Error message component

Example - specified content

<govuk-error-message>Enter your full name</govuk-error-message>

Error message

Example - overriden visually hidden text

<govuk-error-message visually-hidden-text="Gwall">Rhowch eich enw llawn</govuk-error-message>

Error message

Example - ModelState error

<govuk-error-message asp-for="FullName" />

Error message

API

<govuk-error-message>

The content is the HTML to use within the generated error message. Content is required if the asp-for attribute is not specified.

If asp-for is specified and there are no errors in ModelState then no output will be generated. If there are multiple errors only the first will be used.

Attribute Type Description
asp-for ModelExpression The model expression used to generate the error message. If content is specified this attribute is ignored. See documentation on forms for more information.
visually-hidden-text string The visually hidden prefix used before the error message. The default is Error.