Yii 1.1: yii-dynamic-mask

A jQuery based dinamic mask input

A jQuery based dinamic mask input. A wrapper for http://digitalbush.com/projects/masked-input-plugin/

It allows a user to more easily enter fixed width input where you would like them to enter the data in a certain format (dates, phone numbers, etc).

A mask is defined by a format made up of mask literals and mask definitions. Any character not in the definitions list below is considered a mask literal. Mask literals will be automatically entered for the user as they type and will not be able to be removed by the user. The following mask definitions are predefined:

  • 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)


Yii 1.1 or above


Put the files under the application extensions directory.

$this->widget('application.extensions.dynamicmask.DMask', array(
    'element' => '#some_field, #another_field, #one_more_field',
    'mask' => '999-9999-999',
$this->widget('application.extensions.dynamicmask.DMask', array(
    'element' => '#date_field',
    'mask' => '99/99/9999',
    'config' => array(
      'placeholder' => "mm/dd/yyyy",
$this->widget('application.extensions.dynamicmask.DMask', array(
    'element' => '#phone_field',
    'mask' => '(999) 999-9999',


Be the first person to leave a comment

Please to leave your comment.

Create extension