Note: If your screen looks different than the one below, click here.
Validation rules work by testing the field's value with a pre-defined format or a regular expression.
To setup a Validation rule follow these steps:
1. Open Rules
2. Click the field to open the rules box (Email shown here)
3. Click Validation Rules
4. 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
5. Or you can type your own pattern match rule into the Pattern box
6. Then you can choose the level 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
7. Finally, you get to choose the 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