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

236
Visualizações
Adding point as thousand separator, but it adds point after each number point

hello I must have point as a thousand separator. If you type in numbers in the input field, it has to be seen live. The data type is integer. The problem is that the function adds the dots after each number.

function numberDots(x) {
        return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
    }

<div class="form-group">
                                                
       <input type="text" asp-for="inputfield" class="form-control  text-right" onkeyup="this.value=numberWithDots(this.value);"/>
       <span  asp-validation-for="inputfield" class="text-danger"></span>
</div>

this is my code. I want this: 222.222 but I get this: 2.2.2.222

Can you please help me?

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

0

Change your js like below:

function numberWithDots(x) {         
    return x.toString().replace(/^0+/, '').replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ".")            
}
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