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

Numbers in German Local format

Explorer ,
Dec 28, 2023 Dec 28, 2023

Copy link to clipboard

Copied

Hello community.

I'm trying to convert string to number with some text in a text field.

Example:

var stringValue = "1099.33";
var numberValue = parseFloat(stringValue);

var formattedValue = numberValue.toLocaleString('de-DE', {
	minimumFractionDigits: 2,
	maximumFractionDigits: 2,
});

var textValue = "Wir haben " + formattedValue + " EUR.";

 

In this example, I want to achieve this format Wir haben 1.099,00 EUR. (in this format ###.###,###)
It only works in number fields, but not in text fields. Can anyone help me? I appreciate your help and thank you in advance.

TOPICS
JavaScript , PDF forms

Views

354

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 2 Correct answers

Community Expert , Dec 28, 2023 Dec 28, 2023

Use this:

 

var formattedValue = util.printf("%,2.2f", numberValue);

Votes

Translate

Translate
Explorer , Jan 01, 2024 Jan 01, 2024

for me has this format worked.

var stringNumber = this.getField("Number").value;
var formattedNumber = util.printf("%.2f", stringNumber).replace(/\./, ',').replace(/(\d)(?=(\d{3})+,)/g, '$1.');
this.getField("Text").value = "You have " + formattedNumber + " EUR ".;

 For example: Field value is 1299,67. The result was as excepted:

You have 1.299,67 EUR.

Votes

Translate

Translate
Community Expert ,
Dec 28, 2023 Dec 28, 2023

Copy link to clipboard

Copied

Use this:

 

var formattedValue = util.printf("%,2.2f", numberValue);

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
Explorer ,
Dec 28, 2023 Dec 28, 2023

Copy link to clipboard

Copied

Thank you for your support 🙂

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
Explorer ,
Jan 01, 2024 Jan 01, 2024

Copy link to clipboard

Copied

LATEST

for me has this format worked.

var stringNumber = this.getField("Number").value;
var formattedNumber = util.printf("%.2f", stringNumber).replace(/\./, ',').replace(/(\d)(?=(\d{3})+,)/g, '$1.');
this.getField("Text").value = "You have " + formattedNumber + " EUR ".;

 For example: Field value is 1299,67. The result was as excepted:

You have 1.299,67 EUR.

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