Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Default field value when blank

New Here ,
Jul 28, 2017 Jul 28, 2017

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
346
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 28, 2017 Jul 28, 2017

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 28, 2017 Jul 28, 2017

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 28, 2017 Jul 28, 2017
LATEST

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines