Skip to main content

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:

TokenMeaning
#Digit
SLetter
NLetter or digit
ALetter, forced uppercase
aLetter, forced lowercase
XLetter or digit, forced uppercase
xLetter 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 caseMaskExample 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 codeAAA-####ABC-1234
Product codeNNN-NNNA12-B34
Lowercase codeaaa-####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 caseMaskExample 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 0 resolves to a whole-number mask.
  • Decimal Places 2 resolves 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:

RequirementBetter toolExample
Phone number typing shapeMask(###) ###-####
Five-digit ZIP codeMask or Pattern##### or ^\d{5}$
Only letters and spacesPattern^[A-Za-z ]+$
Exactly three uppercase lettersPattern or Mask^[A-Z]{3}$ or AAA
Currency amountNumber validationDecimal Places 2, label Amount (USD)