How would I display JavaScript output numbers in dollar format? I.E. $20.00 then $2,000.00 when the number gets larger. Ok so sample code.
JavaScript
x
7
1
if(this.getField("Account Name RequiredRow1").value !="") {
2
event.value = 20;
3
}
4
else{
5
event.value = "";
6
}
7
Advertisement
Answer
Here’s the function that I use.. Basically the same as @Senad’s except it adds commas:
JavaScript
1
5
1
function(val) {
2
var valString = val.toFixed(2).toString().replace(/B(?=(?:d{3})+(?!d))/g, ",");
3
return "$" + valString;
4
}
5