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

multiplication problem with comma and point

New Here ,
Mar 11, 2019 Mar 11, 2019

Copy link to clipboard

Copied

First of all, I'm pretty new with scripting in PDF Forms.

my case:

I'm trying to create a form with mutliple textfields. The last textfields should multiplicat all other fields togeather so I get a sum in the end.

Thats really easy to do. Every field gets the format of a number with "1.234,56" because the German culture is uses "." as a group separator and "," as the decimal separator.

The script to get the sum in textfield3 is as easy as it can get:

var v1 = this.getField("Text1").value;

var v2 = this.getField("Text2").value;

event.value = v1 + v2;

In Adobe DC pro and Adobe DC reader everything works fine but when I open the form in google chrome directly I get the issue that the calculation goes wrong.

Google Chrome is using the format "1,234.56" instead of "1.234,56". That causes the value to change from, for excample 12,12 to 12012.

Is there any methode to force the PDF in google chrome to use the German culture instead of the English culture?

I can't change any settings in Google Chrome, so the issue must be solved with the PDF itself.

I tried using this validation:

event.value = event.value.replace(/\,/g, ".");

But that caused the sum to be 12,121212 in the end instead of the 24,24 I wanted.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

563

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

Community Expert , Mar 11, 2019 Mar 11, 2019

This is really something you should ask Google... Adobe software does it correctly, and this forum is about Adobe software.

The internal value of a Number field must be in the international standard format, which is no thousands separators and a period used for the decimal separator. The Format setting does not change that value, it only changes how it appears to the user. It seems that the Chrome plugin is using the formatted value literally instead of the underlying value, which is why the addi

...

Votes

Translate

Translate
Community Expert ,
Mar 11, 2019 Mar 11, 2019

Copy link to clipboard

Copied

LATEST

This is really something you should ask Google... Adobe software does it correctly, and this forum is about Adobe software.

The internal value of a Number field must be in the international standard format, which is no thousands separators and a period used for the decimal separator. The Format setting does not change that value, it only changes how it appears to the user. It seems that the Chrome plugin is using the formatted value literally instead of the underlying value, which is why the addition fails. Instead of adding the numbers it is concatenating them as strings. Hence the strange results you're getting.

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