JSFiddle - React, Tailwind, and code Playground

by Park Mino

HTML

<form>
<p>천 단위 콤마 찍기</p>
<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, ","));
});