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

2

10

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

Lahr answered 6/7, 2012 at 1:40 Comment(1)
Have you tried appending a new value (using .val()) to the text box after the plugin is initialized?Shibboleth
R
15

You can redefine masked input definitions like this:

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

And then use this mask:

.mask("129ddd")
Renfrew answered 26/7, 2012 at 7:3 Comment(1)
I still can't find a solution for thisDestination
A
0

This work for me

.mask('+63-Z000000000', {
    translation: {
      'Z': {pattern: /^(9)/}
    },
    placeholder: "+63-9000000000"
  });
Acquiescence answered 13/9, 2024 at 2:27 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.