jQuery does not want to run on mobile

0

I'm using a function so when the person clicks on the inputs the value is replaced by monetary value, but on the mobile phone it only works if the person clicks "ok" or "go", and I wanted it to execute as soon as the person to click on the input.

Code used:

$("#valorsaquemobi").click(function(){
var mask = {
  money: function() {
    var el = this
    ,exec = function(v) {
    v = v.replace(/\D/g,"");
    v = new String(Number(v));
    var len = v.length;
    if (1== len)
    v = v.replace(/(\d)/,"0.0$1");
    else if (2 == len)
    v = v.replace(/(\d)/,"0.$1");
    else if (len > 2) {
    v = v.replace(/(\d{2})$/,'.$1');
    }
    return v;
    };

    setTimeout(function(){
    el.value = exec(el.value);
    },1);
  }

 }

 $(function(){
  $('input#valorsaquemobi').bind('keypress',mask.money)
 });
  });

input:

 <input type="text" class="form-control input-cadastrar rr" id="valorsaquemobi" onclick="mobisaque()">
    
asked by anonymous 26.09.2018 / 17:06

0 answers