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

5.3K

Likes

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

correct answers 1 Correct answer

Community Expert , Mar 22, 2019 Mar 22, 2019

As the custom validation script of the field enter this:

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

Likes

Translate

Translate
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 = "";

Likes

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

Likes

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 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?

Likes

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. 

Likes

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

Likes

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?

Likes

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. 

Likes

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.

 

Likes

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. 

 

 

 

Likes

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.

Likes

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.

Likes

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?

Likes

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.

Likes

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?

Likes

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

Likes

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

Likes

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 = ""

Likes

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

LATEST

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

Likes

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