jaridmargolin / formatter.js

Format html inputs to match a specified pattern
http://firstopinion.github.io/formatter.js
2.48k stars 235 forks source link

Formatter allows 't' to be typed in for certain patterns #66

Open sllvn opened 9 years ago

sllvn commented 9 years ago

Formatter allows 't' to be typed in credit card demo, but not in phone number demo.

Discovered in Chrome on OS X.

kyledetella commented 9 years ago

I ran into the same issue. This is because t returns the keyCode 116 which is mapped to F5 in the isSpecialKeypress method. That makes the t character keypress return true here which subsequently does not prevent the default and does not call _processKey.

I went ahead and simply disabled it in my fork to ensure that was the cause (it was). I am working on providing a better solution that will not break previous functionality required by the F5 mapping. I will submit a PR to this repo once I have gotten that worked out and once my previous PR gets merged (or rejected) so I can clean up my branches.

AustinMontoya commented 9 years ago

@kyledetella: is your current solution still to just comment out the mapping for F5? Were you able to come up with something more elegant?

kyledetella commented 9 years ago

@grrizzly The quick fix was to comment it out. That is certainly less than ideal. I will get around to working on a more practical fix (hopefully) soon.

Also, it looks like there has been some other work around this in #70. That may be something to keep an eye on.

andreyz4k commented 9 years ago

https://github.com/firstopinion/formatter.js/pull/70 is mine. I've looked into rules about key and ascii codes and this looks like the exact solution. I already use it in my app and it works fine. Although I'm not sure if this library actually needs some processing of F5.

mort3za commented 8 years ago

Just forked this repository and merged some of pull requests which also fixes this issue: https://github.com/mort3za/formatterjs2