• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

149
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?

almost 3 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, ".")            
}
almost 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error