JSFiddle - React, Tailwind, and code Playground

HTML

<input id="foo" value="1,2,3,4,5,6,7,890" />

JavaScript

$("#foo").val(function(_,val) {
    return val.replace(/\,/g,'').replace(/\B(?=(\d{3})+(?!\d))/g, ',');
});