Skip to main content
June 10, 2019
Question

If Amount is negative show zero

  • June 10, 2019
  • 1 reply
  • 300 views

I am not familiar with JavaScript and just need it for one application. I have a fill able form that i created.

The Cells used are the following:

Grossamount (manual entry),

2% (=Grossamount*0.02),

SlipFee (manual entry)

The cell i am having trouble with is for the Additional Amount due.

Additional Amount due should be 2% - SlipFee. If the result is negative it should calculate Zero.

For Excel the equation is: =MAX(0,I24-I26) and it works perfectly fine, but i am having issues with that in my pdf file.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
June 11, 2019

You can use this code as the custom calculation script of that field:

var v1 = Number(this.getField("2%").valueAsString);

var v2 = Number(this.getField("SlipFee").valueAsString);

event.value = Math.max(0, v1-v2);