Validation (Regex)

The Validation (Regex) property helps you define a set of validation options for a given field.

In general, this field property is used to perform validation checks (format, length, etc.) on the value that the user enters in a field. If the user enters a value that does not pass these checks, it will throw an error.

You can define validation rules by specifying custom validation regular expressions in this property.

Let’s consider a few examples:

  • Email: If you want to check if the user has entered a valid email address in the email field, you can specify the following regex code in the Validation (Regex) property:
    [a-z0-9!#$%&'*+=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
  • URL: To check whether a URL entered by a user is valid, you can use the following regex code in the Validation (Regex) property:
    ^(http(?:s)?\:\/\/[a-zA-Z0-9]+(?:(?:\.|\-)[a-zA-Z0-9]+)+(?:\:\d+)?(?:\/[\w\-]+)*(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\=[\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$

  • Date: You can define rules to check whether the date entered by a user is in valid format by using the following regex code. The following code will check if the entered value is in one of the "dd/mm/yyyy," "dd-mm-yyyy," or "dd.mm.yyyy" formats. It will also validate leap years.
    ^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$

Note: The Validation (Regex) property is available only for Single Line and Multi Line text box fields.

Learn more about regular expressions in the official documentation.

On This Page

top-arrow