Custom Error Messages in a Form
In the Error Messages tab of the form designer, you can configure custom error messages to appear when users enter invalid inputs in form fields. These messages can appear when required fields are not filled in, or when the input for a field does not meet the conditions specified for that field (e.g. a date that is entered in a date field but not formatted properly). You can configure a single error message to appear for all fields of a certain type, a list of individual fields, or fields with labels match a regular expression.
As an example, we have a file upload field on a form that is configured to accept only files with the extensions jpg and pdf.
When a user tries to upload a file with a docx extension, we can configure a custom error message to be displayed. We want this message to display for all file upload fields on a form for which we specified a list of allowed file extensions, so we configure an error message that says "This type of file cannot be uploaded" when a user tries to upload files of invalid types on any of the file upload fields.
To configure a custom error message
- In the form designer, navigate to the Error Messages tab.
- Click Add Rule.
- Under Display, type the error message that you want displayed. You can insert tokens like the field label and the types of files allowed as part of the error message.
- Under When, choose the type of event that should lead to an error message.
- Under For, select the field types to which the error message rule will be applied.
- If you select All fields, the rule will be applied to all fields in the form. A violation of the condition under When for any field will lead to an error message for that field
- If you select These field type(s), you can choose field types that the error message will apply to when the type of event specified in step 3 occurs. Select a field type from the drop-down menu. To add more than one field type that the error message will apply to, click the + button and specify another field type. Repeat this step until you have specified all the fields that particular condition will apply to.
- If you select These individual field(s), you can choose the specific fields that the error message will apply to. Select one field from the drop-down menu, then click + and select more fields if necessary.
- If you select Fields with label matching, enter a regular expression in the regular expression box to make the condition apply to all fields with labels matching a certain pattern.