jQuery Masked Input - Existing Input Value

plippard picture plippard · May 27, 2011 · Viewed 16.1k times · Source

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.

Answer

Leandro picture Leandro · Oct 24, 2012

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.