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

164
Vistas
Cursor jumps to end of text box while on change formatting

For example I have an input field, so I have entered 100000 in that text. While entering value, I am trying to format 100,000. so if I try to change the value to 100,200, the cursor automatically moved to the end of the text box, so I have tried some solution but I will create another issue.

I have tried this solution, it will create issue like enter image description here the cursor behind one digit before.

        const element = event.target;
        window.requestAnimationFrame(() => {
          element.selectionStart = caretStart;
          element.selectionEnd = caretStart;
        });

 const formatValue = (value: string) => {
    const isDecimalExist = value.split('.');
    if (isDecimalExist.length === 2 && props.decimalPlaces) {
      const formatedValue = `${isDecimalExist[0].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}.${
        isDecimalExist[1]
      }`;
      return formatedValue;
    } else {
      return (value || '')
        .split('.')[0]
        .toString()
        .replace(/\B(?=(\d{3})+(?!\d))/g, ',');
    }
  };
about 4 years ago · Juan Pablo Isaza
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