Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda