> For the complete documentation index, see [llms.txt](https://docs.work-relay.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.work-relay.com/forms/basics/validation-rules-on-form-fields.md).

# Validation rules on form fields

User can configure validation rules for the form fields.

{% hint style="info" %}
User can create validation rules for one of the following field types (both object and virtual fields):

* Date
* DateTime
* Time
* Number
* String
* Textarea
* Rich Text
  {% endhint %}

Select a field to create validation rule for. Click "Add New" button in "Validation Rules" section at the left sidebar:

![](/files/0252220dcd96744686d274dd1a6ca1d6087d996a)

Configure validation rule for the selected field, depending on it's type:

### Text fields

Text fields are the fields of following types: String, Rich Text, Text Area.

![](/files/ee6e2a5d248463f20b7d97c85a6fd87eeaad5260)

1. Set custom **Error Message** that will be displayed under the field if validation fails.
2. Configure **Regular Expression** to validate field input (optional).
3. Set **Minimum Length** for the field input (optional).
4. Set **Maximum Length** for the field input (optional)
5. Configure **conditions** using standard condition builder for validation rule to be executed (optional).

{% hint style="warning" %}
Regular Expression, Min Length and Max Length are optional fields, but at least one of those three should be filled in.
{% endhint %}

#### Example

Validation rule for text field will throw "Invalid value in Sic Desc!" error message if field value contains "BB" substring. It will only run for those inputs starting with "TEST" substring.

![](/files/bd80ec4cdac6096bbb4c905b5de030c857162355)

### Date field

![](/files/6fee24167493f3129bf8aef5f2f41f79459a5d71)

1. Set custom **Error Message** that will be displayed under the field if validation fails.
2. Set **Minimum** (starting) value of the allowed date range (optional).
3. Set **Maximum** (end) value of the allowed date range (optional).
4. Add values to be **excluded** from the allowed date range (optional).
5. Configure **conditions** using standard condition builder for validation rule to be executed (optional).

{% hint style="warning" %}
If Minimum and Maximum values are not provided all dates are allowed to be entered except Excluded date(s).
{% endhint %}

You can choose excluded value type to match your needs:

![](/files/f550303ac3900b1a290292f17071a809231ff440)

#### Example

![](/files/25f35ba8ee4ea76664eb514af736d21a36631633)

Validation rule for date field will throw "Invalid date entered!" error message if user entered the date not within specified date range. It will also through an exception if date value is within the range, but weekday is Wednesday.

### Time field

![](/files/7c4944a34eae34e5d648c4830db0bddcdafa589f)

1. Set custom **Error Message** that will be displayed under the field if validation fails.
2. Set **Minimum** (start) value of the allowed time range (optional).
3. Set **Maximum** (end) value of the allowed time range (optional).
4. Add values to be **excluded** from the allowed time range (optional).
5. Configure **conditions** using standard condition builder for validation rule to be executed (optional).

{% hint style="warning" %}
If Minimum and Maximum values are not provided all time values are allowed to be entered except Excluded values(s).
{% endhint %}

#### Example

![](/files/500d0fd492921b6e80d7b8be2a98e87dc4082851)

Validation rule for time field will throw custom error message if user entered time value within Excluded values time range.

### Number field

![](/files/4f609ad081fd531e261ca91de17faf37e5bc8475)

1. Set custom **Error Message** that will be displayed under the field if validation fails.
2. Set **Minimum** allowed number (optional).
3. Set **Maximum** allowed number (optional).
4. Add values to be **excluded** from the allowed range (optional).
5. Configure **conditions** using standard condition builder for validation rule to be executed (optional).

{% hint style="warning" %}
If Minimum and Maximum values are not provided all numbers are allowed to be entered except Excluded values(s).
{% endhint %}

#### Example

![](/files/eb4a51e5b1f346b7f9f89ed67ab9bed8a1e052ff)

Validation rule for number field will throw custom error message if user entered one of the values in Excluded static values (5 or 10 or 15), entered number between 100 and 150, or entered negative number.
