Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Prevent rounding in number fields

Community Beginner ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

Hello to all,

using Acrobat Pro 2017 (Classic Release), I created a fillable form. In the form I have a column with number fields that have the following field properties according to the screenshots:

adobe_form_01.png

 

adobe_form_02.png

 

As expected, the form contains a 0.

However, numbers with commas can still be entered. In the PDF form, these numbers are then rounded, e.g. 1.99 becomes 2 (compare screenshots):

adobe_form_03a.png

 

adobe_form_03b.png

 

How can I prevent rounding in Acrobat Pro or prevent commas from being entered in the field?

I am already very grateful for tips, ideas and possibly code examples!

I probably won't be able to get around JavaScript.

Regards, Daniel Schunk

TOPICS
PDF forms

Views

290

Likes

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

correct answers 1 Correct answer

Adobe Community Professional , May 17, 2021 May 17, 2021
The entered values are not actually rounded, they are only formatted in a way that hides the decimal digits, because of the Number format you've selected. If you click the field after exiting it, you'll see that the value you entered is still there. Also, if you use it in a calculation it will use the entered value, not the displayed one. So how to prevent the user from entering those decimals? You can't do it with the Number setting under Format, but you can by setting your own Keystroke script...

Likes

Translate

Translate
Adobe Community Professional ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

The entered values are not actually rounded, they are only formatted in a way that hides the decimal digits, because of the Number format you've selected. If you click the field after exiting it, you'll see that the value you entered is still there. Also, if you use it in a calculation it will use the entered value, not the displayed one.

So how to prevent the user from entering those decimals? You can't do it with the Number setting under Format, but you can by setting your own Keystroke script (under Properties - Format - Custom). For example, you can use this one:

event.rc = /^\d*$/.test(event.change);

It will only allow the user to enter digits into the field.

Likes

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 Beginner ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

Hello, try67,

thank you very much for the quick help.

It worked with the code line

event.rc = /^\d*$/.test(event.change);

 

However, I had first put it in the "Custom formatting script" section. That was not correct.

It only works in the "Custom key input script" section, I found.

 

More generally, I must note that the documentation on JavaScript in PDF at Adobe is quite large, but not as immediately obvious as at Microsoft, for example.

 

Best regards,

Daniel

Likes

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
Adobe Community Professional ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

LATEST

I wrote it needs to go under the Custom Keystroke Script...

Likes

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