Input Masking
Input masks guide how a value is typed. They are useful for values with a predictable visible shape, such as phone numbers, ZIP codes, fixed IDs, and numeric precision.
Masks are not full validation rules. Use masks to shape input while typing, and use field validation for rules the completed value must satisfy.
Mask tokens
Text and number masks use the same token set:
| Token | Meaning |
|---|---|
# | Digit |
S | Letter |
N | Letter or digit |
A | Letter, forced uppercase |
a | Letter, forced lowercase |
X | Letter or digit, forced uppercase |
x | Letter or digit, forced lowercase |
Any other character is treated as a literal in text masks, such as (, ), -, /, a space, or x.
Text masks
Text masks are available for Text Input when the input kind is Text, Text Area, or Telephone.
Use text masks when the final value is still text, even if it includes numbers.
Examples:
| Use case | Mask | Example value |
|---|---|---|
| US phone | (###) ###-#### | (555) 123-4567 |
| US phone extension | (###) ###-#### x###### | (555) 123-4567 x890 |
| International phone | +############### | +15551234567 |
| US ZIP code | ##### | 78701 |
| US ZIP+4 | #####-#### | 78701-1234 |
| Employee code | AAA-#### | ABC-1234 |
| Product code | NNN-NNN | A12-B34 |
| Lowercase code | aaa-#### | abc-1234 |
Built-in presets are available for common phone and ZIP formats. A custom mask overrides the selected preset.
Number masks
Number masks are available on Number Input.
Use number masks to control numeric shape and decimal precision. When a number mask is present, the field uses a text-style input with decimal keyboard hints so the mask can control typing.
Examples:
| Use case | Mask | Example value |
|---|---|---|
| Whole number | ################## | 12345 |
| Two decimal places | ##################.## | 12345.67 |
| Three decimal places | ##################.### | 12345.678 |
| Fixed short code | #### | 1234 |
If Decimal Places is set and the Mask field is blank, Nawfe builds a numeric mask automatically:
- Decimal Places
0resolves to a whole-number mask. - Decimal Places
2resolves to a mask with two decimal digit positions.
Number mask limitations
Do not use number masks for currency symbols, unit labels, or other decorative text.
For example, $#.## should not be used on a Number Input expecting the $ to display reliably. Number fields use reverse-fill masking so digits align from the right, and literal prefixes such as $ are not a reliable display mechanism.
Use one of these instead:
- Put the currency or unit in the field label, such as
Amount (USD). - Put the currency or unit in the hint, such as
Enter amount in dollars. - Use a Text Input if the visible formatted value itself is the important value.
- Keep the field numeric and format currency later in tables, emails, exports, or templates.
Number masks also do not replace numeric validation. Use Decimal Places, Minimum, and Maximum to enforce numeric rules.
Pattern validation versus masks
Masks guide typing. Patterns validate the completed text value.
Use a mask when:
- the user needs help entering a known shape
- literals such as parentheses or dashes should appear while typing
- every valid value has the same rough length and layout
Use Pattern (Regex) on Text Input when:
- the final value must match a strict rule
- the rule has optional pieces that a mask cannot express well
- you need to reject completed values after typing
Examples:
| Requirement | Better tool | Example |
|---|---|---|
| Phone number typing shape | Mask | (###) ###-#### |
| Five-digit ZIP code | Mask or Pattern | ##### or ^\d{5}$ |
| Only letters and spaces | Pattern | ^[A-Za-z ]+$ |
| Exactly three uppercase letters | Pattern or Mask | ^[A-Z]{3}$ or AAA |
| Currency amount | Number validation | Decimal Places 2, label Amount (USD) |