function formatNum(num) { if(!/^(\+|-)?(\d+)(\.\d+)?$/.test(num)){alert("wrong!"); return num;} var a = RegExp.$1, b = RegExp.$2, c = RegExp.$3; var re = new RegExp().compile("(\\d)(\\d{3})(,|$)"); while(re.test(b)) b = b.replace(re, &…
function toThousands(num) { var num = (num || 0).toString(), result = ''; //判断是否带小数点 if (num.split('.')[1]) { var numInt = num.split('.')[0], numFlo = num.split('.')[1]; result = formatter(numInt) + '.' + numFlo } else { result = formatter(num); } re…