• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Hide Calculated unused $0.00 form fields.

New Here ,
Mar 22, 2019 Mar 22, 2019

Copy link to clipboard

Copied

Hello, I have an excel spreadsheet that I have turned into a form with Adobe Acrobat Pro that has a qty field, a price field and a total field, among others. I have set the total field to automatically calculate to the product of the Qty field and price field, which works fine. The issue is that by default it displays a zero (or actually, $0.00, since I have it formatted to price), and so if people print out the form to fill it out manually, they have to cross out the zero.

Is custom javascript the only way to get the field to be conditionally hidden or non-printable? If not, can you tell me a better method? If so, can you point me to an example of this that works? I can provide screenshots if necessary.

TOPICS
PDF forms

Views

11.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Mar 22, 2019 Mar 22, 2019

Copy link to clipboard

Copied

As the custom validation script of the field enter this:

if (event.value==0) event.value = "";

View solution in original post

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2019 Mar 22, 2019

Copy link to clipboard

Copied

As the custom validation script of the field enter this:

if (event.value==0) event.value = "";

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2019 Mar 22, 2019

Copy link to clipboard

Copied

PS. In the future you'll be better off posting questions about Acrobat in the Acrobat forums, like this one: PDF Forms

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 17, 2019 Sep 17, 2019

Copy link to clipboard

Copied

I tried this answer but in order to add a custom validation script it deletes your Value is... " " of the following fields statement. Is there a way to add both statements?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 24, 2025 Jan 24, 2025

Copy link to clipboard

Copied

I cannot get any of these formulas to work.  The 0 still shows up no matter what.  I've removed the currency symbol and still have the issue

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2025 Jan 24, 2025

Copy link to clipboard

Copied

Post an example PDF of your attempt to get this to work. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 24, 2025 Jan 24, 2025

Copy link to clipboard

Copied

So I finally got it working.  Pretty ridiculous but if you put the calculation in before adding the script it will not work.  I had to add the script first, and then the formula and then the format for $.  Any other order results in the 0 showing on the form. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2025 Jan 24, 2025

Copy link to clipboard

Copied

So did you read the posted article?  It is not a good idea to use both built in formatting and a script to adjust formatting. But if you do not provide us with the details of what you are trying to do we can not help you to do it correctly.  And it does not seem you are doing it correctly, which can lead to undesired results. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 24, 2025 Jan 24, 2025

Copy link to clipboard

Copied

Ok I see that now.  I had it working but now when I type anything into an unrelated field, it changes all 8 calculated cells to $0.00

 

How would you suggest to make a formula for my total cost cell.  Basically it is a quote form, and the final text field in each row is a calculated product of two other cells.  I want it to show the $ and two decimal places but I also want it to remain blank if the value is $0.00.  The quote form is 8 rows, but if you just put values in the first row and print it, everything else remains blank.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2025 Jan 24, 2025

Copy link to clipboard

Copied

LATEST

So first, read this article:

https://www.pdfscripting.com/public/How-to-set-000-value-to-blank.cfm

Use the Format script example for your form.

 

If there are still issues, post your form with the code you think should be working and we'll take a look at it. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 10, 2020 Feb 10, 2020

Copy link to clipboard

Copied

This isn't working for me. I also have my field formatted to dollar figure. My field's name is ClosingBalance.

I'm inserting 

if (event.value==0) event.value = "";

in the "Run custom validation script" box. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 10, 2020 Feb 10, 2020

Copy link to clipboard

Copied

Post your question to a new thread

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2020 Mar 26, 2020

Copy link to clipboard

Copied

Were you able to get the custom validation script to work with the field being formated with the currency symbol ($0.00)? I am having the same trouble. I can get it to  work if I remove the currency symbol. I don't know much about JavaScript.

 

Does something else need to be included in the script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2020 Mar 26, 2020

Copy link to clipboard

Copied

Do you have a default value set as 0 for the field? That was my issue. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2020 Mar 26, 2020

Copy link to clipboard

Copied

I do not. The only properties I have are:

 

Custom validation script, if (event.value==0) event.value="";

Calculation is product of, QTY Row 1, UNIT PRICE R1

 

The custom validation script will work as long as I change the currency symbol to NONE, but really need this column to be a currency and not just numeric with decimal.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2020 Mar 26, 2020

Copy link to clipboard

Copied

So on my Options tab, there is Default Value. Make sure there's no value in there. 

 

The rest "should" work. Decimal places 2, currency symbol. 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 03, 2020 Aug 03, 2020

Copy link to clipboard

Copied

This is close to the problem I'm having. I have estimated days of inventory on hand (Text53)  as a calculation. Quantity on Hand (Text52) divided by Daily Usage (Text51). So in the simplified field notation I have: Text52/Text51. Only problem is I get errors when I set properties on Text53 to number. I get Java errors. (The Value entered does not match the format of the field [ Text53] So I leave it at none but then it keeps putting NaN in the cell if a number was entered and then cleared. When I clear the form the NaN stays there. I'd like it to go to blank if anything or 0.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 03, 2020 Aug 03, 2020

Copy link to clipboard

Copied

You will get NaN when you divide by zero.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 03, 2020 Aug 03, 2020

Copy link to clipboard

Copied

So how do you get it display blank instead of NaN?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 03, 2020 Aug 03, 2020

Copy link to clipboard

Copied

Use Javascript for the calculation.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 03, 2020 Aug 03, 2020

Copy link to clipboard

Copied

Thank you. I'm still unclear. In the Calculate form properties? Currently is is in simplified field notation: Text52/Text 51. You are saying to use the custom calculation script instead? And what would that Java look like?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 03, 2020 Aug 03, 2020

Copy link to clipboard

Copied

First, you've written that the name of the divisor field is "Text 51". Is this correct? if it is, then the simplified field notation will not work as written anyway. It doesn't like spaces in field name. 

Here's a calculation script that sets the field to blank if  

 

var nDivisor = Number(this.getField("Text 51").value);

if(nDivisor == 0)

  event.value = "";

else

  event.value = this.getField("Text 52").value/nDivisor;

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 09, 2020 Aug 09, 2020

Copy link to clipboard

Copied

Here's an article that discusses this topic in detail:

https://www.pdfscripting.com/public/How-to-set-000-value-to-blank.cfm

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

Type this script into the DEFAULT VALUE box on the OPTION tab (not the RUN CUSTOM VALIDATION SCRIPT on the VALIDATE tab) .  This fixed the issue for me.

 if (event.value==0) event.value = ""

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

That is not possible. You must have a script somewhere else that works for you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines