Make Input Type=“Password” Use Number Pad on Mobile Devices

前端 未结 7 1434
轮回少年
轮回少年 2020-11-29 23:39

On my site designed for mobile devices I have an input field that is used for PIN numbers. I want the text to be hidden as it is entered and I want the number pad to pop up

7条回答
  •  情深已故
    2020-11-30 00:09

    The straightforward ways like using "pattern" and "inputmode" not working in Android nor IOS, so I emplemented the below workaround using CSS, and JavaScript.

    https://jsfiddle.net/tarikelmallah/1ou62xub/

    HTML

     

    JavaScript

    $().ready(function(){
    var xTriggered = 0;
    $( "#passReal" ).keyup(function( event ) {
      $('#pass').val($('#passReal').val());
      console.log( event );
    });
    $( "#pass" ).focus(function() {
      $('#passReal').focus();
    });
    
      });
    

    Style:

    input#passReal{
      width:1px;
      height:10px;
    }
    input#pass {
        position: absolute;
    left:0px;
    }
    

    this image from Android emulator:

提交回复
热议问题