formatter.js icon indicating copy to clipboard operation
formatter.js copied to clipboard

Opera Mobile doubles every char on input

Open viteksafronov opened this issue 11 years ago • 3 comments
trafficstars

I have a classic pattern for credit cards pattern: '{{9999}} {{9999}} {{9999}} {{9999}} {{99}}' When I try to enter the number in Opera Mobile, every digit is entered twice, so I have to delete an extra char.

viteksafronov avatar Sep 04 '14 13:09 viteksafronov

That's a well-known bug. Opera mobile completely ignores preventDefault/return false for keydown and keypress events. There is a simple example which illustrates that behaviour: http://jsfiddle.net/5zrhutra/ Opera mobile is an outdated browser and it won't be updated anymore. Personally, I came to a decision just not to add formatter for opera:

var isOperaMobile = navigator.userAgent.toLowerCase().indexOf('opera mobi/') !== -1;
if (!isOperaMobile) {
    new Formatter(...);
}

kot-lex avatar Oct 01 '14 11:10 kot-lex

All these bugs can be reproduced in Opera Mobile Emulator http://www.opera.com/ru/developer/mobile-emulator

kot-lex avatar Oct 01 '14 11:10 kot-lex

Unfortunately I do not see a solution if preventDefault is ignored. The library depends on this functionality. Perhaps an error or warning should be thrown when using an unsupported browser.

Browser sniffing is an ugly solution, but with so many inconsistencies in browser keyboard handling, it may be the best solution.

jaridmargolin avatar Oct 07 '14 19:10 jaridmargolin