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

268
Views
How do I format with comma a number(value of input) in jQuery?

I want to format with comma a number what a value of input. But, This code is not working. jquery version is 3.6.0.

$(function(){
  $('.bid_btns_add button').on('click',function(){
    var current_value = parseInt($('#bid_price').attr('value'));
    var add_value = parseInt($(this).val());
    var total_value = current_value + add_value;

    var output_value = total_value.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"); //error               
    var output_value = total_value.toLocaleString(); //error

    $('#bid_price').attr('value', output_value);
  });
  $('.bid_btn_clear').on('click',function(){
    $('#bid_price').attr('value',0);
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>

<div class="bid_btns_add">
  <button type="button" class="" value="1000">1000</button>
  <button type="button" class="" value="5000">5000</button>
  <button type="button" class="" value="10000">10000</button>
</div>

<input id="bid_price" type="number" class="input_price" value="0"></input> 
<button type="button" class="bid_btn_clear">x</button>

about 4 years ago · Juan Pablo Isaza
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!