Skip to main content
Known Participant
Oct 15, 2018 1:12 PM UTC
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
Nov 8, 2018 9:51 PM UTC

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
Nov 8, 2018 10:01 PM UTC

The second part of that condition is not necessary.

Translate
hubertl37698266
Inspiring
Nov 6, 2019 1:53 PM UTC

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
Nov 8, 2018 6:03 PM UTC

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