How to Use Custom Validation
Custom validation allows you to define specific rules for input fields using regular expressions (regex).
Note: This option is currently available only for the field types: ‘Text’ and ‘Number’
Basic Regex Patterns
- Letters only: ^[A-Za-z]+$
- Matches any string containing only letters (A-Z or a-z).
- Numbers only: ^\d+$
- Matches any string containing only digits.
- Letters and numbers: ^[A-Za-z0-9]+$
- Matches any string containing letters and/or numbers.
- Email address: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$
- Matches most common email address formats.
- Phone number: ^+?[\d\s-]{7,}$
- Matches phone numbers with optional ‘+’ at the start, and allows digits, spaces, and hyphens.
- UK Postcode: ^[a-zA-Z]2\d[a-zA-Z\d]?\s*\d[a-zA-Z]2$
Quantifiers
- {n}: Exactly n times
- {n,}: n or more times
- {n,m}: Between n and m times
- *: 0 or more times
- +: 1 or more times
- ?: 0 or 1 time
Examples
- 3-10 letters: ^[A-Za-z]10$
- Matches strings with 3 to 10 letters.
- US Zip Code: ^\d5(-\d4)?$
- Matches 5-digit zip codes and optional 4-digit extensions.
- Date (YYYY-MM-DD): ^\d4-\d2-\d2$
- Matches dates in the format YYYY-MM-DD.
For more advanced patterns and detailed explanations, visit RegExr.