This function adds comma to make it look like money value. function addComma(val) { var regEx = /(\d+)(\d{3})/; while (regEx.test(val)) { val = val.replace(regEx, ‘$1’ + ‘,’ + ‘$2’); } return val; }