masked input not working in android mobiles?

后端 未结 8 1181
一生所求
一生所求 2020-12-14 15:17

I am using the digitalbush masked input jQuery plugin. It is working fine in web browsers and the iPhone browser perfectly, but it is not working for Android mobile devices.

相关标签:
8条回答
  • 2020-12-14 15:39

    This was fixed awhile ago but for some reason the distribution posted on the website never took the changes. If you grab from the raw source, the fix works: https://raw.githubusercontent.com/digitalBush/jquery.maskedinput/master/src/jquery.maskedinput.js

    0 讨论(0)
  • 2020-12-14 15:40

    I just ran into this problem and resolved it by removing the attribute type="number" from the asp textbox. After that masked input worked even on mobile devices.

    0 讨论(0)
  • 2020-12-14 15:43

    After trying different mask libraries (Inputmask, ui-mask, ngMask) I ended up using jQuery-Mask-Plugin https://igorescobar.github.io/jQuery-Mask-Plugin/ which works pretty well and is also lightweight and well documented and has angularjs, react ,... samples.

    0 讨论(0)
  • 2020-12-14 15:46

    This can be a quick fix:

    var ua = navigator.userAgent;
    var isAndroid = /Android/i.test(ua);
    var isChrome = /Chrome/i.test(ua);
    
    // Fix masking on Chrome for mobile devices
    if (isAndroid && isChrome) {
        $('.price_input').attr('type','tel');
    }     
    
    0 讨论(0)
  • 2020-12-14 15:47

    The library used in the question is no longer being maintained. I switched my application to jQuery Mask Input as it works great, has a very similar base init call to the former library making for an extremely easy transition and, at the time of this post, jQuery Mask Input is regularly maintained at GitHub.

    My issue was with the phone number masker moving the cursor back to the second position when 3 or 4 digits were entered. The cursor continued to act odd after that point. The problem was noticed using jQuery Masked Input v1.4.1 (old library) in android tablets using Chrome post major version 51.

    0 讨论(0)
  • 2020-12-14 15:51

    I resolved this issue with three actions, which have fixed this for all Android 4.0+ phones:

    1. Update masked-input to at least version 1.4
    2. Add type="tel" to the input, to trigger the numeric keyboard
    3. Remove the input's maxlength attribute or set it to a value certain not to interfere with the caret action, like 20.
    0 讨论(0)
提交回复
热议问题