Skip to main content
Dorothy26138473siql
Known Participant
August 8, 2023
Question

Script - round down and remove $0.00

  • August 8, 2023
  • 1 reply
  • 314 views

Hello, I am currently using this as a custom validation script. This takes a value, divides it in two and rounds down, the rounds down part is key. 

 

var v = Number(this.getField("GST2").valueAsString) / 2;
var nDecimals = 2;
event.value = Math.floor(v * Math.pow(10, nDecimals)) / Math.pow(10, nDecimals);

 

I need the field to not show the $0.00 and still round the result down, so $1.05 is rounded down to .52 cents, if that makes sense, I know it needs this if (event.value==0) event.value = "" but I can n ot get it to work. 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 8, 2023

- This should be a calculation script, not a validation one.

-Adding the code you posted to the end of your current code should take care of the zero values and not display them.