Form Validation documentation for the dotCMS Content Management System

Default Field Validation Messaging

When creating forms as content, form field validation is automatically handled as seen in the image below.   If the fields are required on the form structure, or if a non-matching data type is submitted to a form field, an error message will automatically be generated to the user asking them to re-supply the invalid field information on the form.  The warning message will display the label of the form field as defined in the form structure.

Creating a new form

Custom Field Messaging on Forms

To add custom field validation messaging to a form, simply edit the field(s) on a structure, click on the “Field Variables” tab, and add a field variable with “errorFieldMessage” (case sensitive), as the Key of the field value.   If this field property is set, then the custom messaging typed in the Value field for the Field Variable will be displayed instead of the default validation messaging on the form.

Custom Field Messaging on Forms

As shown below, if the required field has not been supplied on submit, then the custom validation messaging will be displayed.