//"123,456.78"----> 123456.78(float格式) function rmoney(s) { return parseFloat(s.replace(/[^\d\.-]/g, "")); } //参数说明:num 要格式化的数字 n 保留小数位 //formatNum(12345.675910, 2),返回12,345.67 var formatNum = function(num,n) { num = String(num.toFixed(n)); var re = /(-?\d+)(\d{3})/; while(re.test(num)) num = num.replace(re,"$1,$2") return num; }