functionformatNum(num)
{
if(!/^(\+|-)?(\d+)(\.\d+)?$/.test(num)){alert("wrong!");
returnnum;
}
vara=RegExp.$1,b=RegExp.$2,c=RegExp.$3;
varre=newRegExp().compile("(\\d)(\\d{3})(,|$)");
while(re.test(b))b=b.replace(re,"$1,$2$3");
returna+""+b+""+c;
}
【JS将数字转换成三位逗号分隔的形式】