RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.39k stars 2.17k forks source link

Masking characters pushed when typing in the input field on Kindle Gen 6 Devices #443

Closed nitishdhar closed 10 years ago

nitishdhar commented 10 years ago

Hey,

There is a weird issue on specific kindle devices (Gen 6) If a field has input masking applied, when user goes inside the field & starts typing, instead of the masking characters getting consumed as user types in, the characters are just pushed forward in the input field.

Eg:

( ) - __ - ___

If the above the the masking. Once user starts typing, it goes like this -

999( ) - -

This happens with the other masking library as well - http://digitalbush.com/projects/masked-input-plugin/

Any idea what could be causing this. I understand this is something kindle's browser is not understanding, but can you tell me which part handles this & if some workaround can be implemented to make it work.

Thanks a lot.

RobinHerbots commented 10 years ago

@nitishdhar,

That is because the keydown keypress input keyup events aren't handled correctly on android based devices.See #434

If you have a look into the jquery.inputmask.js and search on mobileinputevent you can reënable handling off input solely based on the inputevent; This will work in some cases but isn't 100% reliable. See issues for android browsers.

best regards, Robin

RobinHerbots commented 10 years ago

Is there an emulator for the Kindle Gen 6?

Can you test which events get fired on keystroke especially on non-numeric input. On chrome for android it is only in the case of non-numeric input the events aren't fired.

RobinHerbots commented 10 years ago

ok found it

https://developer.amazon.com/sdk/fire/setup.html

nitishdhar commented 10 years ago

alright. Also you mean i need to specify the input type to be number & it works in some cases?

nitishdhar commented 10 years ago

and could you please explain this - "you can reënable handling off input solely based on the inputevent;" I am not sure what I should do.

nitishdhar commented 10 years ago

also, we are in the process to migrate to the new masked library (this one) but we are currently using the old one, would it be too much to ask for, if you could help with a fix for this in this library - https://raw.github.com/digitalBush/jquery.maskedinput/1.3.1/dist/jquery.maskedinput.js

thanks

RobinHerbots commented 10 years ago

@nitishdhar ,

No I mean if you use a mask like 999-999-999 it will work on android chrome but a mask like aaa-aaa not. This is because in the case of the aaa-aaa mask the keydown keypress events aren't fired.

In the code there is an attempt to handle this, but it is commented out see #434.

Sorry, but I don't have time to solve bugs of another masking library and even if I had, I don't have a fully working solution for the issue.

Maybe we should take a look at the source of Chromium

nitishdhar commented 10 years ago

sure thanks a lot.. ill keep you posted if anything works

nitishdhar commented 10 years ago

Hey,

I got it working with your library by un-commenting that mobileinput event part & also adding another device check for kindle -

kindle = /Kindle/i.test(ua) || /Silk/i.test(ua) || /KFTT/i.test(ua) || /KFOT/i.test(ua) || /KFJWA/i.test(ua) || /KFJWI/i.test(ua) || /KFSOWI/i.test(ua) || /KFTHWA/i.test(ua) || /KFTHWI/i.test(ua) || /KFAPWA/i.test(ua) || /KFAPWI/i.test(ua);

RobinHerbots commented 10 years ago

@nitishdhar,

And is the backspace and typing more characters then possible correctly handled?

nitishdhar commented 10 years ago

yes everything is handled properly.

nitishdhar commented 10 years ago

http://jsfiddle.net/ftnU7/8/

RobinHerbots commented 10 years ago

Which browser is the kindle using as default?

2014-03-06 21:50 GMT+01:00 Nitish Dhar notifications@github.com:

http://jsfiddle.net/ftnU7/8/

— Reply to this email directly or view it on GitHubhttps://github.com/RobinHerbots/jquery.inputmask/issues/443#issuecomment-36935257 .

nitishdhar commented 10 years ago

I guess it uses the webview of Silk browser.