Field validation
Validate text patterns using regular expressions or allowing only numerical input
Regular Expressions (Regex) are sequences of characters that define a search pattern in text. You can use them to validate text based on complex criteria and match common text patterns like phone numbers and IP addresses. Regular expressions are both flexible and powerful, capable of matching virtually any text-based pattern you might want to include in a form.
If you don't want to check for specific patterns but want to narrow down inputs to numbers, you can enforce this validation by allowing only numbers in the input field. This will narrow down possible errors when providing postcodes, identifiers or bank account numbers.
Validation of short text fields
When you create your form, you can decide what type of field input is allowed. To help you eliminate possible input errors, you can decide to enable field validation for the short text fields.
Based on the type of input you expect, you can also create a customized message users will see when they provide incorrect data.
For limitations in the supported regular expressions, see Syntax (external page).
You can use this external page to test if your expression is correct.
Common regex examples
Input | Expression | Validation | Input match | Example of validation message |
---|---|---|---|---|
IBAN | ^[A-Z]{2}\\d{2}[A-Z0-9]{1,30}$ | Checks for IBAN structure | DE89370400440532013000 | The IBAN has incorrect format |
German IBAN | ^DE\\d{2}\\d{8}\\d{10}$ | Ensures the IBAN follows the structure for German accounts and is 22 characters long | DE89370400440532013000 | Ensure this is a German IBAN |
Supplier identifier | ^[A-Z]{2}\\d{6}$ | Ensures that the identifier follows the pattern of 2 uppercase letters followed by exactly 6 digits | NL336789 | This is not a correct identifier |
Postcode | ^\\d{5}$ | Checks for 5 digits | 85774 | Ensure the code has five digits |
Value greater than 0.00 | ^([1-9]\\d\_(\.\\d{1,2})?|0?\.[1-9]\\d?)$ | Check whether the value is greater than 0.00 | 2.54 | Enter a value greater than 0.00 |
Positive value or 0 | ^(0|[1-9]\\d\*)(\.\\d{1,2})?$. | Check whether a value is a positive number or 0. Allow decimals. | 0.12 | Enter a positive value or 0 |
Email addresses with a specific domain | ^[a-zA-Z0-9._%+-]+@mycompany\.com$ | Validates email addresses that end with "@mycompany.com" | [email protected] | This is not a correct domain |
Price format with comma for decimal and dot for thousands | ^[1-9]\\d{0,2}(\.\\d{3})\*(,\\d{2})?$ | Validates European-style formatted numbers with optional thousands separators and exactly two decimal places | 1.234,56 or 1.234.567,89 | Enter the price separating thousands with a point |
Note that the operation doesn't support Pearl syntax in the editor. This means that look-around expressions such as:
(?=...)
, (?!...)
,(?<=...)
, or(?<!...)
are not supported. This refer to all posivite and nehative lookahead expressions and positive and negative lookbehind expressions.
Updated 23 days ago