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

Rounding Validation script for Adobe Acrobat

Participant ,
Dec 16, 2024 Dec 16, 2024

Copy link to clipboard

Copied

I'm hoping someone can help me out with a validation script where the answer will round to 0.  So, if the script results in an amount of $83,333.33, I'd the validation script to round this to 0 or in this case the answer would be $83,333.00.  I have no idea how to write this one.  this is where i'm stuck:   if(event.value==

 

Thank you for any feedback on this one.

 

 

TOPICS
JavaScript , Modern Acrobat , PDF forms

Views

191

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
1 ACCEPTED SOLUTION
Community Expert ,
Dec 16, 2024 Dec 16, 2024

Copy link to clipboard

Copied

This is not very accurate. It should actually be:

 

/*your calculation goes here*/

event.value=Math.round(event.value);

View solution in original post

Votes

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 ,
Dec 16, 2024 Dec 16, 2024

Copy link to clipboard

Copied

Shouldn't it be a calculation script? 

event.value=Math.round(/*your calculation goes here*/);

Votes

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
Participant ,
Dec 16, 2024 Dec 16, 2024

Copy link to clipboard

Copied

This doesn't work.  I have a calculation script in place already.  I want to validate the result of the script.  Seems to me that i could do something like this to validate the result:

 

if(event.value>0)event.value=Math.round(/*event.value*/;

Votes

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 ,
Dec 16, 2024 Dec 16, 2024

Copy link to clipboard

Copied

That won't work.  The validate script runs before the calculation script.  What is your calculation script?

Votes

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 ,
Dec 16, 2024 Dec 16, 2024

Copy link to clipboard

Copied

You can use validate script, because when field value changes (due to calculation script) then validation script will trigger.

You could also input rounding directly into your calculate script.

What exactly are you trying to round, just decimals?

Votes

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 ,
Dec 16, 2024 Dec 16, 2024

Copy link to clipboard

Copied

This is not very accurate. It should actually be:

 

/*your calculation goes here*/

event.value=Math.round(event.value);

Votes

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 ,
Dec 17, 2024 Dec 17, 2024

Copy link to clipboard

Copied

2/3; //Your calculation

event.value=Math.round(event.value);

returns 0.00 (field formatted to 2 decimals).

event.value=Math.round(2/3);

returns 1.00 (0.66667 rounded)

Votes

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
Participant ,
Dec 17, 2024 Dec 17, 2024

Copy link to clipboard

Copied

LATEST

This works perfectly!!!  Thank you.

Votes

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