How i can do like just auto add comma after each entered number. example like : 1,2,3,4 if i add number 5 after 4 so it should separate with the comma. here is my code.
function addComma(txt) {
txt.value = txt.value.replace(",", "").replace(/(\d+)(\d{3})/, "$1,$2");
}
<input type="text" id="txt" onkeyup="addComma(this);" />
the comma are seperating after few numbers. I require auto add comma after each number has been entered.