Home > OS >  Add a currency comma in a PDF when format is already used to display an "event.value" in a
Add a currency comma in a PDF when format is already used to display an "event.value" in a

Time:04-07

(Click on link to see image) Circled in red, is the prefilled text box that needs to reformat in currency when a user adds the amount

I'm a real novice when it comes to Javascript. The text field in a PDF form already has javascript shown below in the text field properties under "Custom" format to prefill the box to state "Check Amount", which disappears when a user types in the text field or when the cursor is in the text field. The struggle is because it has the Custom prefilled javascript, I can't change it to a "Number" format in the properties when a user adds an amount for currency (for instance, add a comma if it's in the thousands). How can I combine the prefilled text "Check Amount" and add a comma (",") when a user puts an amount, such as "$3,500.35".

if (!event.value) { 
event.value = "Check Amount";
event.target.display = display.noPrint;
} else {
event.target.display = display.visible;
}

How do I add a currency format to it?

I've seen this javascript by KHKonsulting LLC, but the prefilled text of "Check Amount" disappears completely:

var f = this.getField("SomeField");
f.setAction("Format", "AFNumber_Format(2, 0, 0, 0, "", true);");
f.setAction("Keystroke", "AFNumber_Keystroke(2, 0, 0, 0, "", true);");

CodePudding user response:

Adding the javascript line below changed the number to US currency:

event.value = util.printf("%,0.2f",event.value);

  • Related