JSFiddle - React, Tailwind, and code Playground
by Praveen Kumar Purushothaman
HTML
<form>
<input class="test" type="text" />
</form>
JavaScript
$(document).on('keyup', '.test', function() {
var x = $(this).val();
$(this).val(x.toString().replace(/,/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
});