Copy link to clipboard
Copied
Hi, A would like to set this kind of format in number field: 1 221,00 1 546 684,54 154,00 etc.
I know one way:
event.value = util.printf("%,2.2f",event.value).toString().replace(/\./gim," "); BUT if number field is empty, it shows "0,00".
ButI don't want to see "0,00" in empty number fields, just nothing. Could anybody help ? Robert
Copy link to clipboard
Copied
I'm just throwing this out there maybe someone else will chime in....
Would it be possible to put in an if statement??
var checkForZeros = this.getField("the field name").value;
if (checkForZeros == "0,00") {
// then hide the field
}
Just a thought
Copy link to clipboard
Copied
This is the code I use when I don't want zero to show for a blank field:
if(event.value == 0 | event.value == '') event.value = '';
Copy link to clipboard
Copied
The second part of that condition is not necessary.
Copy link to clipboard
Copied
Complete code to add in the Format script
if(event.value == 0 | event.value == '')
{
event.value = '';
}
else
{
event.value = util.printf("%,2.2f",event.value).toString().replace(/\./gim," ");
};
Thanks for the previous info....
Copy link to clipboard
Copied
The "or" symbol in your if statement is incorrect. The single bar "|" is a bitwise OR, you want a logical OR
if(event.value == 0 || event.value == '')
Copy link to clipboard
Copied
Thanks Thom!
I am getting better thanks to your material..........on pdfscripting.com
It has helped me so much build nice forms.
Copy link to clipboard
Copied
You're Welcome! Happy to help
Find more inspiration, events, and resources on the new Adobe Community
Explore Now