Wednesday, May 23, 2012

How to use the "Masked Input" module in Drupal 7

I am trying to build a form in Drupal 7, one of the fields needs to have an input mask. I found the plugin masked input it seems like what I am searching for . Only there is no documentation on how to implement it (I read about currency and this plugin, yet here it is only about getting it to work).

I am new to Drupal, but searching on forums I came up with the following code:

function report_expenses_form($form, &$form_submit) {
libraries_get_path('maskedinput') . '/misc/ui/jquery.maskedinput-1.3.js';
$form['cash_advance']['amount'] = array(
'#title' => t('Cash Advance : '),
'#type' => 'textfield',
'#default_value' => t('$ 00,00'),
'#required' => TRUE,
'#mask' => '$?999.999.999,99',

I installed the "Libraries" and "Masked Input" plugins in Drupal and flushed my caches.

I downloaded the jquery.maskedinput-1.3.js and put it in my {DRUPAL_HOME}/misc/ui/

any Ideas?

thank you in advance

1 comment:

  1. I wish I could.. I am also stuck. I did exactly like you did on my custom form and nothing is working. Did you manage to get it right?