Skip to main content
Known Participant
April 25, 2019
Answered

adding text and a dollar sign to a custom format text field

  • April 25, 2019
  • 1 reply
  • 3578 views

I'm trying to add a script to the custom format window of a text field so I can have the results show like this - $22.33 per foot (or whatever dollar amount entered). I've been playing around with this bit of code but cannot get it to do as I want. Can someone help me out? Here's the javascript that comes close

AFNumber_Format(2,0,0,0,"$/ per foot",false);

This topic has been closed for replies.
Correct answer try67

Try this:

if (event.value) {

    event.value = "$" + util.printf("%,0.2f", event.value) + "/ per foot";

}

1 reply

try67
Community Expert
Community Expert
April 25, 2019

What's the issue? It works fine for me, except the dollar sign appears after the number, instead of before it, but there's not much you can about that, unless you write your own Format script.

pdfUser1Author
Known Participant
April 25, 2019

yeah, that's what it does for me as well. But, I don't want the dollar sign after the number. I thought it would be possible and an easy thing to do. I can get the script to do one way or the other. But, I cannot figure it out, how to get it to write the correct way I'd like.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 25, 2019

Try this:

if (event.value) {

    event.value = "$" + util.printf("%,0.2f", event.value) + "/ per foot";

}