Skip to main content
Inspiring
January 15, 2016
Question

Hide zero in field with an if/else formula

  • January 15, 2016
  • 2 replies
  • 521 views

Hi, I’m able to hide the zero in fields when fields have simple calculations, using as the last line:  if (sum !==0) {event.value = sum;} else {event.value = ""}

I have a field named LessRetainage with an if/else formula, and the formula works fine, but I’m not sure how to hide the zero, I’ve tried various versions and the zero still appears, any advice on the syntax of a line that would hide the zero would be appreciated.  Below is the formula:

var Contract = this.getField("TotalContractToDate");

var TCW = this.getField("TotalCompletedWorkStoredMaterials");

var Retainage = this.getField("LessRetainage");

if (TCW.value <=(.5 * Contract.value)) {Retainage.value = .05 * TCW.value} else {Retainage.value = .025 * Contract.value}

Thanks!

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
January 15, 2016

Ass this at the end of your code:

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

Inspiring
January 15, 2016

The script you provided works with numeric values which do not have currency symbols or Percentage symbols. The latest versions of Acrobat seem to accept your script even if there are currency symbols present.

With older versions of Acrobat we used the AFNumber_Format function to modify the displayed result to include the currency symbol or not display it.