I want to use Jquery.Inputmask to mask a phone number input and I'm dong it as follows:
@Html.TextBoxFor(m => m.PhoneNumber, new {@class = "form-control mask-phone"})
and in my JS I initialize it:
$(".mask-phone").inputmask({
mask: "(99)9{4,5}-9999}",
greedy: false
});
and it works great, but the dynamic input is triggered right after the sixth digit and i have to manually put the caret after the hyphen. Is there a way to only trigger the dynamics in the mask after the very last digit has been typed?
I'm not sure I made myself clear. I short terms, I want a mask that goes from:
(99)9999-9999
to:
(99)99999-9999
without having to drag the caret after typing the sixth digit.
4 years after: the solution for this case is now in the Input mask documentation, under 'keepStatic' option. So in this case you could do somthing like this:
$(".mask-phone").inputmask({
mask: ["(99)9{4}-9999", "(99)9{5}-9999"],
keepStatic: true
});