Skip to main content
Known Participant
October 15, 2018
Question

number field formatting

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

This topic is closed to new replies. Start a new post to keep the conversation going.

7 replies

Participating Frequently
November 8, 2018

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 = '';

Translate
try67
Community Expert
Community Expert
November 8, 2018

The second part of that condition is not necessary.

Translate
hubertl37698266
Inspiring
November 6, 2019

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....

Translate
subieguy2
Inspiring
November 8, 2018

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

Translate