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 | ^(?!0+(\.0{1,2})?$)\\d+(\.\\d{1,2})?$ | Check whether the value is greater than 0.00 | 2.54 | Enter a value greater than 0.00 |
Email addresses with a specific domain | ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.mycompany\.com$ | Validates email addresses that end with "@mycompany.com" | [email protected] | This is not a correct domain |
Updated 5 days ago