Masks
Masks restrict the characters that can be entered in a field. If a user attempts to enter a character that is not within the parameters set by a mask, the character is not accepted. Validation is performed on a character-by-character basis. Masks also can be used in fields that will always have data entered in a specific manner, such as telephone numbers and identification numbers.
The following are examples of masks:
Example |
Mask Expression |
Description |
---|---|---|
Social Security Number (XXX-XX- XXXX) |
[\d]{3}-[\d]{2}-[\d]{4} |
This regular expression will match a hyphen- separated Social Security Number (SSN) in the format XXX-XX-XXXX, where X is any integer. Matches: 333-22-4444, 123-45-6789 Non-Matches: 123456789, SSN |
Date (MM/DD/YYYY) |
[\d]{1,2}\/[\d]{1,2}\/[\d]{4} |
This expression matches dates of the form XX/XX/YYYY, where XX can be 1 or 2 digits and YYYY is always 4 digits. Matches: 4/1/2001, 12/12/2001, 55/5/3434 Non-Matches: 1/1/01, 12 Jan 01, 1-1-2001 |
Phone Number (XXX-XXX- XXXX) |
[2-9][\d]{2}-[\d]{3}-[\d]{4} |
This expression matches a hyphen separated U.S. phone number, of the form ANN-NNN- NNNN, where A is an integer between 2 and 9 and N is an integer between 0 and 9. Matches: 800-555-5555, 333-444-5555, 212- 666-1234 Non-Matches: 000-000-0000, 123-456-7890, 2126661234 |
Time (HH:MM) |
([0-1][0-9]|2[0-3]):[0-5][0-9] |
Validate an hour entry to be between 00:00 and 23:59. Matches: 00:00, 13:59, 23:59 Non-Matches: 24:00, 23:60 |
Decimal Number (XX.XX) |
[-]?([1-9]{1}[0-9]{0,}(\.[0- 9]{0,2})?|0(\.[0- 9]{0,2})?|\.[0-9]{1,2}) |
This regular expression will match on a real/decimal/floating point/numeric string with no more than 2 digits after the decimal. The negative sign (–) is allowed. No leading zeroes or commas. Matches: 123, 123.54, –.54 Non-Matches: 123.543 0012; 1,000.12 |
Percentage (%) |
[-+]?[0- 9][\d]{0,2}(\.[\d]{1,2})?%? |
Required and regular expression validator. For supporting –999.99 to +999.99. Positive and negative integer/ decimal validations. Percentage sign also is supported. This expression will not allow empty strings. Can increase/decrease the range as needed. Matches: 12.3, 123, –123.45 Non-Matches: –, 10.1234, –1234 |
Integer |
[-+]?\d* |
Matches any integer number or numeric string, including positive and negative value characters (+ or –). Also matches empty strings. Matches: 123, –123, +123 Non-Matches: abc, 3.14159, –3.14159 |
Currency |
This mask will use the user- defined currency settings in Suite Manager. |