Skip to main content
Participant
October 22, 2023
Answered

How to add dash character as a starting one in a text field that contains number (currency) form?

  • October 22, 2023
  • 2 replies
  • 1488 views

Hello,

Im using Adobe Acrobat Pro DC

 

I've added a formula containing numbers and currency, to the text field. I cannot add any non-numeric character and would like the starting character in that text field to be a dash (-).

I've tried to add some exeptions to the form that contains dash as a character accepted by the formula but it didn't work.

 

Is there any solution to my problem? Im so lost about solving it...
If someone can solve my problem please, answer and help me.

Thank you in advance,
Makeover

This topic has been closed for replies.
Correct answer Nesa Nurani

It's a custom format script not calculation, if you wish to add 'dash' when field is empty use this as 'Custom format' script (it includes 2 decimals with the Polish zloty currency sign:

if(event.value)
event.value = util.printf("%.2f zł", event.value);
else
event.value = "-";

 

2 replies

Nesa Nurani
Community Expert
Community Expert
October 23, 2023

Even if you set format as number, you can still use 'dash' character, so if you set number format as number with 2 decimals with dollar sign for currency you can enter -10, and it will show as -$ 10.00 although if you use it in a calculation it will be a negative number.

You can use this script as custom format script that will also add currency sign and 2 decimals:

if(event.value)
event.value = "-"+util.printf("$%,0.2f",event.value);

Participant
October 23, 2023

Hi,
Okay, I pasted your script in the Calculate -> Custom calculation script window, but it didn't work. A message still pops up in which the program informs me about the incorrect format of the entered character.

I would also like to add that what I mean is to add a possibility to an existing formula, the possibility of adding a dash to fill an empty field (for example, we do not fill it in when entering costs and I want to insert a dash there instead of leaving the field empty). Number formula and in my case The Polish zloty must remain and I want to add functionality to it, an exception, etc., containing a dash.

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
October 23, 2023

It's a custom format script not calculation, if you wish to add 'dash' when field is empty use this as 'Custom format' script (it includes 2 decimals with the Polish zloty currency sign:

if(event.value)
event.value = util.printf("%.2f zł", event.value);
else
event.value = "-";

 

JR Boulay
Community Expert
Community Expert
October 23, 2023

Place this script as a Format script in the text field:

 

event.value = "-" + event.value;

 

A format script does not change the value, it change only the display.

Acrobate du PDF, InDesigner et Photoshopographe
Participant
October 23, 2023

Hi, thanks for the response.
I've done it and it works, but not in the way that i wanted.
Custom Format Script is available by selecting Custom in the Format pane. But this is equal to the fact that my numeric + currency formula that I wanted to leave must be disabled.
Is there any other option to add a dash without having to remove the existing form?