Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

165
Visualizações
Error keyup doubles characters when used on mobile responsive

I found a keyup error while creating a function that automatically add the thousand separator when typing in input. Everything works fine on desktop browser but error occurs when using it on mobile responsive. Below is the js code that I used:

$('input.number').keyup(function(event) {
  if(event.which >= 37 && event.which <= 40) return;
  $(this).val(function(index, value) {
    return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")
    ;
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input class="number">
</input>

Example : I type 1000000 on computer browser and it shows exactly 1,000,000 but shows 100,010,000 on mobile responsive.

I found another code like this on Fiddle but same error. The phone I used to test is also Android OS version 7, The version of Chrome is 93.0.4577.62

So how to fix this error? Does anyone have any suggestions for me? Any suggestions are appreciated!

Thanks so much!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I have tested in all browsers and everything works fine. The main problem probably lies in the uncommon aspect ratio of the S8 Plus. How to fix: add input event that triggers whenever the input changes. Input works both on desktop as well as mobile phones.

$('input.money').on('keyup input',function(event) {
  //code
});

I hope it can help those who have the same problem. More detail at jQuery Input Event.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda