Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

masked input not working in android mobiles?

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.

My issue : mask is in input field _ - _ - ___.

When I type numbers it will 12345685555___--

Example: http://rossbender.com/temp/mask.html

Any suggestions? How can I solve this?

Thanks Prasad.

like image 638
Durga Prasad Avatar asked Aug 26 '13 10:08

Durga Prasad


3 Answers

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.
like image 91
Tony Brasunas Avatar answered Oct 15 '22 01:10

Tony Brasunas


I tried using the raw script that Jonathan Rowny mentioned, but I was still having the same problem on an S3 - Chrome browser. I think it has something to do with inputs type="tel" and/or type="number". I ended up having to use another plugin. http://igorescobar.github.io/jQuery-Mask-Plugin/

jquery-mask (not to be confused with jquery-masked-input) is very similar but the syntax was slightly different. Hope this helps anyone else with this issue.

jquery-masked-input syntax: $("#phone").mask("(999) 999-9999");

VS

jquery-mask syntax: ('#phone').mask('(000) 000-0000');

like image 33
duyn9uyen Avatar answered Oct 15 '22 03:10

duyn9uyen


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

like image 3
Jonathan Rowny Avatar answered Oct 15 '22 02:10

Jonathan Rowny