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

Numbers in German Local format

Explorer ,
Dec 28, 2023 Dec 28, 2023

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
583
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
2 ACCEPTED SOLUTIONS
Community Expert ,
Dec 28, 2023 Dec 28, 2023

Use this:

 

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

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

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

Use this:

 

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

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

Thank you for your support 🙂

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