Default field value when blank

New Here ,
Jul 28, 2017

Copy link to clipboard

Copied

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?

TOPICS
Acrobat SDK and JavaScript, Windows

Views

113

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

Default field value when blank

New Here ,
Jul 28, 2017

Copy link to clipboard

Copied

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?

TOPICS
Acrobat SDK and JavaScript, Windows

Views

114

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
Jul 28, 2017 0
Adobe Community Professional ,
Jul 28, 2017

Copy link to clipboard

Copied

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);

}

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
Reply
Loading...
Jul 28, 2017 0
New Here ,
Jul 28, 2017

Copy link to clipboard

Copied

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.

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
Reply
Loading...
Jul 28, 2017 0
Adobe Community Professional ,
Jul 28, 2017

Copy link to clipboard

Copied

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.

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
Reply
Loading...
Jul 28, 2017 0