Optional ninth digit using Jquery Mask Plugin

Asked

Viewed 37 times

0

How can I make Jquery Mask Plugin formatting automatically fit the number of digits? for phones with 8 digits and/or 9 (optional), it looks like this:

$(document).ready(function() {
    $('#phone').mask('(00) 00000-0000');
}); 

Output: (71) 9999-9999 (8 digits)

Correct output: (71) 8888-8888

And when it’s nine:

Output: (71) 98888-8888

  • I found the solution in the plugin page for this specific problem: https://igorescobar.github.io/jQuery-Mask-Plugin/

  • But the duplicate is not from the same plugin.

  • Managed to solve? As there the question asks Mask Plugin, I think it would fit you to post an answer there. So whoever finds either of the two questions will be pointed to the same solution. And let us know, because besides helping others, you get a few points.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.