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

How to replace comma with dot in form field

New Here ,
Mar 09, 2021 Mar 09, 2021

I'm trying to create a field in a PDF that might contain decimal numbers and calculates this field with another field. As an example, when I write 2.3 in the fillable field, the equation works, but when I write 2,3, the result is NaN. I want to replace the comma I wrote in the field with a dot, or if there is some other workable solution to make this calculation work, I exept all solutions. I have tried with JavaScript (value.replace (/, /, '.')) But I can not make it to work or I'm placing it to a wrong place or something. Please notice that I'm not good at coding.

 

Can anyone help with this?

TOPICS
Create PDFs , How to , JavaScript , PDF forms
5.0K
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
1 ACCEPTED SOLUTION
Community Expert ,
Mar 09, 2021 Mar 09, 2021

If you want to write , and field to show , but to calculate as decimal try select this option:

Izrezak.PNGexpand image

View solution in original post

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 ,
Mar 09, 2021 Mar 09, 2021

Why not simply use the built-in Format option that has a comma as the decimal separator? That will allow you to enter the value directly with the comma, and will handle it correctly in later calculations.

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
New Here ,
Mar 09, 2021 Mar 09, 2021

Tried that. If I write 2,3 it gives me back 23.00? 

 

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 ,
Mar 09, 2021 Mar 09, 2021

What option did you select under the Format tab?

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 ,
Mar 09, 2021 Mar 09, 2021

Also, make sure to remove the code you applied earlier, which removes the comma from the text...

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
New Here ,
Mar 09, 2021 Mar 09, 2021

Thanks for your tip. Actually right now all the Format tab options calculate right??? Nesa Nuranis code workes also. I don't know what happened, but thank you for your tips. 

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 ,
Mar 09, 2021 Mar 09, 2021

That's exactly what I suggested you do, but OK...

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
New Here ,
Mar 09, 2021 Mar 09, 2021

Yep, it just didn't work the first time I tried it. Maybe closing and re-opening the file did something and this suggestion started to work. 

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 ,
Mar 09, 2021 Mar 09, 2021

So you want to write 2,3 but field to show 2.3?

try this as custom format script:

event.value = event.value.replace(",",".");

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 ,
Mar 09, 2021 Mar 09, 2021

If you want to write , and field to show , but to calculate as decimal try select this option:

Izrezak.PNGexpand image

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
New Here ,
Jul 26, 2023 Jul 26, 2023

Is there a way to edit all fields at once? Because if I choose more than one field the window "format" doesnt show up, only when I choose a single field.

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 ,
Jul 26, 2023 Jul 26, 2023
LATEST

Not manually. It can be done using a script, though, like this (paid-for) one I've developed:

https://www.try67.com/tool/acrobat-apply-format-to-multiple-text-fields

 

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
New Here ,
Mar 09, 2021 Mar 09, 2021

This worked perfectly. Thank you very, very much!!

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