optional mask caractére with Jquery maskedInput does not work

Asked

Viewed 1,277 times

6

In a form that I am developing, one of the fields that the user needs to fill is cellular, and as the cellular of some regions of Brazil have 9 digits I am using the library jQuery Maskedinput to format the data entry.

The problem is that when I create the mask $("#celular").mask("(99) 9999-9999?9"); the character ? appears in the input this way (__) ____-____?_, what wasn’t supposed to happen.

I used this same formatting on a previous system that worked perfectly, I can’t understand why in this case it is not working.

The plugin I’m using is this one digitalbush.com/Projects/Masked-input-plugin Someone could help me?

  • could put the code you have so far?

  • Put your code because I made a test with your mask and it works, give a look = https://jsfiddle.net/4xon0s6e/

  • In HTML it looks like this: <input type="text" name="cellular" id="cellular" placeholder="DDD + CELLULAR" value=""/> E in javascript it looks like this: $(Document). ready(Function(){ $("#cellular").Mask("(99) 9999-9999?9"); }); What I find strange is that in another system of mine everything is working ok, and in this one it is left here (_) -?

  • Here also worked. You can give more details of your code?

1 answer

1

By your example it was meant to work.

I have worked on several projects and whenever we use a mask plugin, we give preference to http://igorescobar.github.io/jQuery-Mask-Plugin/

This I guarantee, and way to use is very similar, in my opinion is the best!

Hug I hope I helped you

Browser other questions tagged

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