Javascript Number currencyDisplay()
Number.prototype.currencyDisplay = function() { var num = this.valueOf().toString() var value = Number(num); var res = num.split("."); if(num.indexOf('.') === -1) { value = value.toFixed(2);/* w w w. j a v a 2 s . com*/ num = value.toString(); } else if (res[1].length < 3) { value = value.toFixed(2); num = value.toString(); } return num };