JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="numCom">
JavaScript
document.getElementById("numCom").addEventListener("click", TextChanged());
function numberWithCommas(x) {
return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
}
function TextChanged(){
document.getElementById("numCom").value = 'awesome'
var fixed = numberWithCommas(text_VAL);
text_VAL = fixed
}