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

87

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 , 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;
	}
}

Likes

Translate

Translate
Adobe Community Professional ,
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. 

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

Copy link to clipboard

Copied

And what might that be?

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 ,
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;
	}
}

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

Copy link to clipboard

Copied

LATEST

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

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