9

I am using jQuery masked input plugin. However when I set the mask, any existing value in the input field is being destroyed. Doing the following:

$(".priceSKUID").mask("**-***-******", { placeholder: " " });

There must be a way to deal with existing values which are programmatically placed into the input field.

1
  • 1
    Masked Input is a little limited and bugged. Can you try meioMask? Is very similar. Commented May 27, 2011 at 2:09

3 Answers 3

3

When you set a mask like 9999, the value of the input has to be 9999. But, if we have a mask with some optional characters like 9?999, it means that if the value have just one character, it will be displayed. In other words, the last three characters are opitional. I just tried it and works fine.

Sign up to request clarification or add additional context in comments.

Comments

3

$('#my').mask('99.99').val('25.00') is not working

It should have trigger('input')

$('#my').mask('99.99').val('25.00').trigger('input')

Comments

2

You can set it vía javascript after calling

<input id='my' />

...

$('#my').mask('99.99').val('25.00')

You must honor the mask format by setting the value this way. Its not that simple but is the only way i found to achieve this goal.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.