Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Masked Input

Security covered Under active development 852 sites

This module allows you to enforce specific input formats for text fields, such as phone numbers or social security numbers. It provides a configurable widget and API for applying these masks to form elements.

Sometimes you need the user to input data in a particular format like a Social Security Number or a standard US phone number. By masking input of a particular textbox, you can change its behavior so that it accepts input only according to specified format, e.g. a masked phone number input box will only allow 10 digits of of the phone number to pass through and won’t accept any other input.

This module provides the Masked Input Plugin by Josh Bush.

Drupal 8 users:

Currently this module only works with Field type
1) Text(Plain)
2) Text(Formatted)
3) Text(Formatted,long)

Drupal 7 users:

This module includes:

  • A fully configurable field widget
  • A form element
  • A small API for embedding this feature on existing form elements
  • A user interface for configuring your own mask definitions
  • Drush integration
  • Drush make example file

You are free to use this module in the same fashion that is described for the Drupal 6 version, all you'll need to do is include the script from code using Libraries API

libraries_get_path('maskedinput') . '/jquery.maskedinput-1.3.js';

Drupal 6 users:

There is a simple configuration page that allows you to enter each field you want masked along with simple masking parameters.

Use the following format: $("#YOUR-FIELD-ID").mask("YOUR-MASK");

Where "YOUR-FIELD-ID" is the CSS ID of the textfield you want to mask and "YOUR-MASK" is one of the following

  • a - Represents an alpha character (A-Z,a-z)
  • 9 - Represents a numeric character (0-9)
  • * - Represents an alphanumeric character (A-Z,a-z,0-9)

Examples:

$("#phone").mask("(999) 999-9999");

$("#tax-id").mask("99-9999999");

$("#ssn").mask("999-99-9999");

$("#prod-num").mask("a*-999-a999");

$("#pct").mask("99%");

Optionally, if you are not satisfied with the underscore ("_") character as a placeholder, you may pass an optional argument to the maskedinput method.

$("#YOUR-FIELD-ID").mask("99-999999",{placeholder:"+"});

Version 2.0 authored and maintained by Helior Colorado
Version 1.0 authored and maintained by Tim Wooten

Ask your assistant about Masked Input

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
1
Tracked since
Apr 2024
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core PHP Release date
2.0.0-beta2 Pre-release 8–10 Apr 9, 2024