Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 73964

How i can add comma after each entered number only

$
0
0

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.


Viewing all articles
Browse latest Browse all 73964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>