Can jQuery add commas while user typing numbers?
Run the code snippet to see it work $(‘input.number’).keyup(function(event) { // skip for arrow keys if(event.which >= 37 && event.which <= 40) return; // format number $(this).val(function(index, value) { return value .replace(/\D/g, “”) .replace(/\B(?=(\d{3})+(?!\d))/g, “,”) ; }); }); <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js”></script> <input class=”number”>