Skip to main content
Participant
Jul 28, 2017 3:31 PM UTC
Question

Default field value when blank

I am creating calibration certificates, my fields are set as numerical values, but I cannot leave a blank field when data is not available. How can I default the blank fields with "--" using javascript?

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

3 replies

Inspiring
Jul 28, 2017 3:47 PM UTC

I would set the field's format to "Custom" and write a custom format script that displays the symbols "--" when empty an the formatted number when number when not blank.

// Custom format field set to format on "Custom";

if(event.value == "")

{

event.value = "--";

} else {

event.value = util.printf("%,2 1.2f", event.value);

}

Translate
discoboy1Author
Participant
Jul 28, 2017 3:52 PM UTC

It works!, but some fields have calculations and return 0.00 when data is not filled, so the script does not work in that case.

Translate
Inspiring
Jul 28, 2017 6:52 PM UTC

I used the script in a form field that calculated the future value. Note that "" or null string is different from a value of 0.

Translate