> //return the amount in the money format .99 (/^\d+\.\d{2}$/)
> //used round() function
> toMoney=function(amount) {
> var a=round(amount);
> return(a==Math.floor(a))?a+'.00':((a*10==Math.floor(a*10))?a+'0':a);
> }
В денежный формат можно и короче:
function fn(n){
return String(n).match(/\./)?(n+"0").match(/\d+\.\d\d/):n+".00"
}
Это уже было на форуме:
http://dhtml.ru/talk/common/876/