Pattern match validation rules work by testing the field's value with a regular expression pattern. Common patterns have been provided in the Pattern Tools that can be dragged and dropped into the rule designer to quickly create pattern match rules.
Custom patterns can be created by entering your own regular expression pattern.
To setup a Pattern Match rule follow these steps:
1. Open Rules
2. Click the field to open the rules box
3. Click Add a Rule under Validation Rules
4. Click Pattern Match
5. If you wish to use a preset pattern match rule, you can drag and drop a pattern from the right sidebar into the Pattern box
6. Or you can type your own pattern match rule into the Pattern box
7. Then you can choose the Failure Severity of either warning or error. A warning will allow a document to submit successfully even if the entry does not conform to the pattern match. An error will prevent a document from submitting until the user fixes the entry to conform to the pattern match
8. Finally, you get to choose the Failure Message that will be displayed in the app with the field and entry.
Custom Pattern Examples:
1 to 5 digits |
|
Expression |
^(\d{1,5}$ |
Matches |
1 | 11| 111 | 1111 | 11111 |
Non-Matches |
a | 111111 |
4 digits |
|
Expression |
^(\d\d\d\d)$ |
Matches |
1111| 2222| 1234 |
Non-Matches |
aaaa| 1 | 11111 |
Value 1 to 9 |
|
Expression |
^(1-9)$ |
Matches |
1| 2 | 9 |
Non-Matches |
a| 0 | 11 |
At least 5 characters |
|
Expression |
^(\D{5,}$ |
Matches |
aaaaa | aa11aa| 11111 | 1111111111 |
Non-Matches |
a | aa |aaaa | 1111 |
4 upper case characters |
|
Expression |
^([A-Z]{4})$ |
Matches |
AAAA | BBBB | 111 | 1111 | 11111 |
Non-Matches |
aaaa | 1111 | AAA1 | |
US Zipcode |
|
Expression |
^(\d{5})$ |
Matches |
11111 | 12345| 45400 |
Non-Matches |
abcde | 11111 | 11111-1111 |
US Zipcode+4 |
|
Expression |
^([0-9]{5}(([-])?){1})+([0-9]{4})$ |
Matches |
11111-1111 | 22222-2222 |
Non-Matches |
11111-11111 | 111111 | 2 |
US Social Security Number |
|
Expression |
^(?!000)([0-6]\d{2}|7([0-6]\d|7[012]))([ -]?)(?!00)\d\d\3(?!0000)\d{4}$ |
Matches |
078-05-1120 | 078 05 1120 | 078051120 |
Non-Matches |
987-65-4320 | 000-00-0000 | (555) 555-5555 |
To test your regular expression and learn more, visit: http://www.rubular.com
Comments