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

Script - round down and remove $0.00

Explorer ,
Aug 08, 2023 Aug 08, 2023

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. 

TOPICS
How to , JavaScript
284
Translate
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 08, 2023 Aug 08, 2023
LATEST

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

Translate
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