Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!