Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Mask Field

Security covered Maintenance fixes only 1,083 sites

This module allows you to add input masks to form fields, ensuring data is entered in a specific format, such as for phone numbers or ZIP codes. It provides a field widget for content types and can be used in custom forms via the Form API.

This module uses the jQuery Mask Plugin to enable adding masks to input fields. By masking the user input, the provided values are restricted to only the allowed formats. Examples of data that should be masked include phone numbers, ZIP codes and IP addresses.

This module offers:

  • Field widget settings to add masks to fields. Several Drupal's widget types are supported out-of-the-box. Others can be easily added by third-party modules - by providing a my_module.mask_widget_types.yml file.
  • A Form API property ("#mask") to enable masking form elements in custom forms. The supported form elements include "textfield" and "tel". More can be easily added by third-party modules - with the help of the Drupal\mask\Helper\ElementHelper class.

Basic usage

After enabling the module at admin/modules, go to your content type's Manage form display page, e.g. admin/structure/types/manage/article/form-display. Click the gear icon of the fields that are using supported field widgets to change mask settings.

Currently, the supported field widgets are:

  • Textfield
  • Telephone

Please refer to the module's documentation for more detailed information.

Differences from the Masked Input module

The Masked Input module also provides means to mask Drupal fields. However, there are main differences from the Mask Field module that should be pointed out:

  • The Masked Input module provides a field widget to be used with some of the Drupal's built-in field types. On the other hand, the Mask Field module provides additional settings for existing field widgets.
  • The Mask Field module works with the Drupal's Telephone field type out-of-the-box.
  • The Mask Field module provides a Form API element to mask fields in custom forms using the "#mask" property.
  • The Mask Field module provides an extensible mechanism based on Drupal's Plugin API to allow third-party modules to integrate their own field types with it.
  • The Masked Input module uses the Masked Input plugin by Josh Bush whilst the Mask Field module uses the jQuery Mask Plugin by Igor Escobar.

Ask your assistant about Mask Field

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
5
Tracked since
Jan 2023
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Slowing

Release Timeline

Releases

Version Type Core PHP Release date
2.1.0-rc1 Pre-release 10–11 Dec 3, 2024
2.1.x-dev Dev 10–11 Dec 3, 2024
2.0.0-alpha4 Pre-release 9–10 Aug 11, 2023
2.0.0-alpha3 Pre-release 9–10 Mar 14, 2023
2.0.0-alpha2 Pre-release 9–10 Jan 21, 2023