Skip to main content

Masked input

Note: There are deprecated versions of this component. Switch to a version of the docs older than 10.3.x to view their docs.

Usage

Overview

An input mask guides users in entering data by constraining and shaping the information into a specific format as it is entered.

You can apply a mask to the text input field and the phone input field.

When to use

In fields with a specific expected format such as Social Security Number or ZIP code.

When not to use

  • For input that requires a free-form field.
  • When the input pattern is too complex for a mask. For example, an email address has many possible scenarios for input.

Formatting

Anatomy

Image depicting the anatomy of a phone input field with an input mask Example of the phone input field with an input mask.

  1. Label: Describes the purpose of an input field.
  2. Input mask: A string expression that constrains input to support valid input values. The input mask appears on focus.
  3. Phone input field: Enhanced field that enables users to enter their phone number. It only accepts numeric inputs and is automatically formatted.

Content

For content standards, refer to text input and phone input writing guidelines.

Behaviors

The input mask appears as soon as there is a focus on the field. Before focus, the input is empty or displays placeholder text.

Image illustrating the text input field in the enabled state and focus state Example of an enabled text input field (on the left), and a focused text input field (on the right).

Accessibility

This component has been validated to meet the WCAG 2.2 AA accessibility guidelines in its default, base configuration. This includes ensuring:

  • The contrast ratio of textual elements against their background is above 4.5:1.
  • Non-textual content that needs to convey meaning (like icons and focus indicators) has a contrast ratio of at least 3:1 with its adjacent colors.
  • The item is operable using a keyboard, as well as using a mouse.
  • Content is accessible using screen readers, such as JAWS and VoiceOver.

Accessibility conformance ultimately depends on how this component is implemented and customized. Changes made by the content author can affect accessibility. For details on our shared responsibility model, please review our full Jutro accessibility statement.

When using this component within your application, ensure that labels and instructions are meaningful and concise. Provide supplemental instructions if necessary.