Applying Form Validation

Apply validation to elements to:

  • Force the form user to provide an answer.

  • Specify criteria that must be met.

  • Provide custom error messages.

The types of validation available depend on the element selected.

You can apply validation when the element is created or later in the element's settings.

Elements and their validation types

Element Element Type Validation Type
CAPTCHA Advanced Automatic
Checkbox Basic Force Check
Country Select Advanced Force Value
DoB Basic Force Value
Date Picker Advanced Force Value
Email Basic Automatic
Postal Code Advanced Automatic
Radio Basic Force Value
Select Basic Force Value
Text Area Basic Validation Rule
Text Box Basic Validation Rule

The validation on CAPTCHA, email, and post code is automatic, meaning the user must enter valid data for these elements to submit the form.

Force check and force value

Use Force Check and Force Value validation to prevent form submission until the checks/values are entered.

  • Force check - commonly used for Terms & Conditions, etc.

  • Force value - used when a field is considered mandatory for your database, e.g. making sure someone includes their name when completing a form.

Validation rule

A validation rule has two different forms of complexity:

  • Not empty - the form field must contain a value of some kind for the form to be submitted.
  • Advanced - define a type of value required in the field, such as particular characters or words, using a regular expression.

Regular expressions allow complex pattern matching, e.g. a customer number in a particular format, or a telephone number.

Adestra supports PCRE expression syntax.

Example: expression to match a UK postcode.

^[a-z]{2}\d{1,2} ?\d{1,2}[a-z]{2}$

This would match a string:

  • Starting with two letters [a-z]{2},

  • Followed by one or two numbers \d{1,2},

  • With an optional space ( ?),

  • and ending with one or two numbers \d{1,2},

  • followed by two letters [a-z]{2}.

Adding a custom error message

If you use validation on an element you will be shown the custom error message text area.

Enter a custom error message to display if validation of an element fails., e.g. customer reference needs to be ten characters and begin with either an A or a Z.

You can leave this blank and the default error message will show, i.e. '<label>' is invalid.