JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<input type="number">
</form>
JavaScript
$('input').keyup(function(){
var $this = $(this);
var num = $this.val().replace(/,/g, '');
// the following line has been simplified. Revision history contains original.
$this.val(num.replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"));
});