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

168
Visualizações
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 à 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