Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pre-populate 9 with jQuery Masked Input Plugin?

I am using Masked Input Plugin from digitalBush for jQuery, which is very simple to use.

For some cases, I want to pre-populate data for the client, so for something like this :

.mask("123999")

client will see:

123___

And will need to insert last 3 digits. It's working fine till the moment I want to pre-populate number 9, to show something like this:

129___

When I am making mask as "129999", user see 12____

Is it even possible to have mask with this plugin that is visible for the user as 129___?

like image 693
Ivan Sokalskiy Avatar asked Jul 06 '12 01:07

Ivan Sokalskiy


1 Answers

You can redefine masked input definitions like this:

$.mask.definitions['9'] = '';
$.mask.definitions['d'] = '[0-9]';

And then use this mask:

.mask("129ddd")
like image 68
Alexey Busygin Avatar answered Oct 13 '22 01:10

Alexey Busygin