10
votes

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___?

1
Have you tried appending a new value (using .val()) to the text box after the plugin is initialized?Control Freak

1 Answers

15
votes

You can redefine masked input definitions like this:

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

And then use this mask:

.mask("129ddd")