Cognito Forms logo

Advanced validation

  1. Requiring fields
  2. Custom errors

Requiring fields.Requiring fields

Requiring a field will make sure the user provides a response. When a field is required, an error message will display, and the form cannot be submitted until a value has been added to the field. Required fields are indicated by a red asterisk next to the label. By default, fields are never required.

To make a field required, click on the field. The field's settings will appear to the left side of the builder canvas. Select the appropriate option under the Require This Field section:

  • Always - Field is always required. User must provide a response in order to submit the form.
  • When - Field is required only when specific conditions are met. After selecting this option, the Conditional Logic Builder dialog will display allowing you to select when the field is required.
  • Never - Field is not required. This is the default behavior.

Custom errors

With the "Show Custom Error" option (located in the settings area of almost every field type), you can set a custom error message that will display under your field when certain criteria become true. Using both advanced and conditional logic, you can add any number of rules for validating your field.

  • By default, the Show Custom Error option is set to Never. When you select When, two sections will appear:

Specify your custom error message.

  • In the first section, you can open the conditional logic builder and specify the conditions that will result in a validation error for the field. For example, you can set a Date field so that users cannot select Sunday as the day of the week:

Choose when to show your custom error.

  • Once your rules are in place, you can write an error message in the second box:

Custom error completed.

  • So, when a user fills out the date field and selects a Sunday, they will see a custom message explaining exactly what the error is:

The error will display beneath the field.

Related posts

Learn more about what you can do with custom error validation, including:

  1. Ensuring that two fields have the same value
  2. Preventing duplicate choices
  3. Displaying alternate messages
  4. Requiring specific answers
  5. Capitalize a Name field


Printable View