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

negative dollar amount format

New Here ,
May 22, 2022 May 22, 2022

Copy link to clipboard

Copied

A client would like negative dollar amounts in her form to be displayed with parentheses, minus sign, and dollar sign (e.g., "(-$12.34)"), in addition to being red. How do I do that?

 

TOPICS
PDF forms

Views

465

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 , May 23, 2022 May 23, 2022

Try this code:

 

if (event.value) {
	if (Number(event.value)<0) {
		event.target.textColor = color.red;
		event.value = "(" + util.printf("%,0.2f", event.value).replace("-", "-$") + ")";
	} else {
		event.value = "$" + util.printf("%,0.2f", event.value);
		event.target.textColor = color.black;
	}
}

Votes

Translate

Translate
Community Expert ,
May 22, 2022 May 22, 2022

Copy link to clipboard

Copied

The built-in options that will do it will not display the minus-sign, so you'll need to write your own custom Format script to achieve it. 

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
New Here ,
May 22, 2022 May 22, 2022

Copy link to clipboard

Copied

And what might that be?

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
Community Expert ,
May 23, 2022 May 23, 2022

Copy link to clipboard

Copied

Try this code:

 

if (event.value) {
	if (Number(event.value)<0) {
		event.target.textColor = color.red;
		event.value = "(" + util.printf("%,0.2f", event.value).replace("-", "-$") + ")";
	} else {
		event.value = "$" + util.printf("%,0.2f", event.value);
		event.target.textColor = color.black;
	}
}

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
New Here ,
May 26, 2022 May 26, 2022

Copy link to clipboard

Copied

LATEST

Seems to work (though I have no idea why)! Thanks!

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