Android Information
See original GitHub issueI have found some information that I hope is useful for Android. I have found that this library still breaks on Galaxy devices. I started to look into what was causing some of these issues. As of right now, Galaxy devices are not registering the keys that are pressed. It instead returns 0 for the keydown/up events. I have written several tests to see if I could replicate the issue and spent several days scratching my head to why they were passing when I could clearly break it.
The Jasmine tests that I have written are similar to yours but they are returning a false positive on input. As you can specify in code what key is pressed and so the mask is working if it receives a keycode. Although if it receives keycode 0 (null in Ascii) it does not know how to handle that and allows input before the mask no limit to the number of characters entered.
Here is some of the tests that I have used for trying to identify the problem. For these tests I was using your sendKey and sendKeys methods.
beforeEach(function () {
jasmine.getFixtures().set('<input type="tel" id="test"/>');
inputField = $('#test');
});
describe("SSN", function () {
var deleteInput = function () {
for (var i = 0; i < inputField.val().length; i++) {
inputField.sendKey(keys.BACKSPACE);
}
};
beforeEach(function () {
inputField.inputmask("999-99-9999");
});
it("applies a mask to the field with MaskedInput attribute", function () {
inputField.val('1');
expect(inputField.val()).toEqual("1__-__-____");
});
it("allows deletion of the input", function () {
inputField.val('333224444');
deleteInput();
expect(inputField.val()).toEqual("");
});
it("allows input after deleting input from field", function () {
inputField.sendKeys('333224444');
deleteInput();
expect(inputField.val()).toEqual("");
inputField.sendKeys("123");
expect(inputField.val()).toEqual("123-__-____");
});
it("allows inserting values with INSERT mode on", function () {
inputField.sendKey(keys.INSERT);
inputField.sendKeys("123");
expect(inputField.val()).toEqual("123-__-____");
});
});
Hope this helps with the advance on Android and mobile devices. 😄
Resources: Thread on the return 0 issue: https://code.google.com/p/chromium/issues/detail?id=118639 Test for return 0: http://goo.gl/n7IKjF
Issue Analytics
- State:
- Created 9 years ago
- Comments:46 (20 by maintainers)
Top GitHub Comments
I finded temporary solution for phone mask. Set type input field as “tel”
My device Samsung Galaxy S3
Was facing same issue, and as quick fix - switched to another library. But they also had exactly same problem and it was fixed, check here.