Module Description
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.
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.
Module Link
Project Usage
659
Security Covered
Covered By Security Advisory
Version Available
Production
Module Summary
This module aims to solve the problem of adding masks to input fields in Drupal, restricting user input to specific formats like phone numbers, ZIP codes, and IP addresses.
Data Name
mask