Pattern Validation for Text
In case you need to control the format of the data being entered to a Text column, use the validation option. It can be activated in the Advanced Options section of the Text column settings.
- Validation
- This checkbox activates the validation specified in the
Pattern
field. - Pattern
- Here you should specify the format, that should be applied to text column values.
Character | Meaning |
---|---|
0 or # | Any digit: 0 to 9 |
A | Uppercase latin letter: A, B… to Z |
a | Lower latin letter a, b to z |
Z or z | Any latin letter |
? | Latin letter or digit |
* | Any character |
\ | Suppresses any special meaning of the character that follows, e.g. \* means star |
any other | Treated literally |
If a simple pattern is not enough, you can still use regular expressions. Start pattern with regex: and put expression afterwards, here are some examples:
- regex:^d{3,5}$ means 3 to 5 digits are allowed
- regex:0\d*$ means leading zeros and digits 0 to 9 are allowed.
- Message
- If a user input does not match the pattern, the message specified in the
Message
property is displayed.
Validation Format Examples
Here are couple of samples:
- \0000 0000 0000 0000 - credit card number (4 groups by 4 digits)
- (000) 000-0000 - US phone number
- \000-00-0000 - SSN
- \00000 - Five-digit postal code
- A0A 0A0 - Canadian postal code
- ???-???-???-???-??? - 25 characters product key (5 groups by 5 letters or digits)
Also, text input was modified to let it handle format on the fly. When focus leaves input field and the input’s value does not contain invalid characters, we reformat it according to the pattern: remove extra spaces, insert required punctuation, convert lowercase letters to uppercase and vice versa. For example, following Canadian postal code pattern, k1 a0 b1 transforms to K1A 0B1.