How to replace comma with dot in form field

New Here ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

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

Views

85

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 , Mar 09, 2021 Mar 09, 2021
If you want to write , and field to show , but to calculate as decimal try select this option:

Likes

Translate

Translate
Most Valuable Participant ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

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

 

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

Copy link to clipboard

Copied

What option did you select under the Format tab?

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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. 

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

LATEST

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. 

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

Copy link to clipboard

Copied

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

try this as custom format script:

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

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

Copy link to clipboard

Copied

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

Izrezak.PNG

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

Copy link to clipboard

Copied

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

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