Accessibility guidelines recommend specific, meaningful error messages when required form elements are empty. However, when implementing native HTML5 form validation, it is not possible to support custom error messages for required elements (browsers by default throw a hard-coded "Field xyz is required." error).
Since Backdrop 1.23.0, a new #required_message
optional property is supported in Form API elements, which allows specifying a custom message. If set, the text specified in this property will be used when a required form element is left empty, instead of the default "Field xyz is required." text.
Introduced in branch:
1.x
Introduced in version:
1.23.0
Impacts:
Module developers
Theme developers
Related Github Issues: