I am trying to get numbers with commas using JavaScript but it's not working. Please check my code and let me know where I went wrong. Please don't mark this question as a duplicate; I know this question has been asked before, but it's not helping me. Thanks in advance. Here is what I have tried-
function numberWithCommas() {
var x = document.getElementById('abc').value;
x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
html code-
<input type="text" onblur="calculate(); numberWithCommas()" name="abc" id="abc" placeholder="abc" />