function nubmerFormat(amount){ var formatted; var ret_amt; var amt = amount; if(typeof amount == 'number'){ amt = amount.toString(); } if(amt.length <= 3) { formatted = amt; amt = ''; } else if(amt.length == 4) { formatted = amt.substr(0,1) + ","; amt = amt.substr(1); } else if(amt.length == 5) { formatted = amt.substr(0,2) + ","; amt = amt.substr(2); } else if(amt.length == 6) { formatted = amt.substr(0,1) + ","; formatted += amt.substr(1,2) + ","; amt = amt.substr(3); } else if(amt.length == 7) { formatted = amt.substr(0,2) + ","; formatted += amt.substr(2,2) + ","; amt = amt.substr(4); } else if(amt.length == 8) { formatted = amt.substr(0,1) + ","; formatted += amt.substr(1,2) + ","; formatted += amt.substr(3,2) + ","; amt = amt.substr(5); } else if(amt.length == 9) { formatted = amt.substr(0,2) + ","; formatted += amt.substr(2,2) + ","; formatted += amt.substr(4,2) + ","; amt = amt.substr(6); } else if(amt.length == 10) { formatted = amt.substr(0,3) + ","; formatted += amt.substr(3,2) + ","; formatted += amt.substr(5,2) + ","; amt = amt.substr(7); } ret_amt = formatted + amt; // ret_amt = formatted + amt + ".00"; // console.log(ret_amt); return ret_amt; }