View Full Version : Adding commas and dollar signs

February 14th, 2013, 09:07 AM
I am sure this has been asked and discussed in maybe a different way. But I have search the forums and can't find a simple solution.

I have 5 data fields with dollar amounts in them. None have commas, or dollar signs.

In a perfect world I would just use the Number to Currency wizard for all 5 fields that FusionPro gives however....

Not all the data in those fields are numbers, some is text and they change whereas sometimes the "Other $_______ may be in field named AMT1 position.

Amt1= 25
Amt2= 50
Amt5=Other $________

Amt1= Other $________
Amt2=(Blank--will be suppressed)
Amt3=(Blank--will be suppressed)
Amt4=(Blank--will be suppressed)
Amt5=(Blank--will be suppressed)

Amt1= 25
Amt2= 50
Amt3=Other $________
Amt4=(Blank--will be suppressed)
Amt5=(Blank--will be suppressed)

I need to make it where the rule searches the field for numbers only and convert to currency formatting. And if it has text do not format.

February 14th, 2013, 11:02 AM
Assuming you're trying to list these in one text field, this might work for you:

var amt = [];

for (var i=1; i<=5; i++){
(Field("Amt" + i) != "") ? amt.push(Field("Amt" + i)) : "";

return amt.join("<br>").replace(/(\d+)/g,function(n){return FormatNumber("$###,###,###.00",n);});