Skip to main content
Known Participant
August 14, 2017
Answered

Why is the blank field script not working in my pdf?

  • August 14, 2017
  • 9 replies
  • 1863 views

I created a template in Scribus and added pdf forms fields before saving it as a pdf. I then opened the pdf in Adobe Acrobat Pro 9 and entered the following scripts in my percentage fields, but neither worked.


if(event.value == 0 | event.value = "") event.value = "";

if( Number(event.value) == 0) event.value = "";


I entered each on their own, but neither worked. I also tried entering them in the "Run custom validation script:" and "Custom Calculation Script" sections and neither worked.

Currently, my form will print out "0.00%" when no value is inputted into said fields. I want the fields to print blank if no value is entered.

Any help is highly appreciated, thanks!

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

Whoa, that sounds really out of my javascript league atm. I guess for now I'll simply restrict the field to number entries - rather than having it be a percentage field - and place a non-editable "%" text field besides it. If the field is blank, then the only thing that'll print out is the "%" sign which is better than the full "0.00%." Thanks for helping me out.


You can get pretty good results with pretty simple code, actually... As the custom Format script enter this:

if (event.value) event.value = event.value+"%";

And as the custom validation script enter this:

if (isNaN(Number(event.value))) event.rc = false;

This will basically only allow the user to enter numbers (they could still type non-number characters, but they will be rejected), as well as an empty string, and will add the percentage symbol to any non-empty value.

9 replies

try67
Community Expert
Community Expert
August 14, 2017

You can't set a Percentage field to be completely empty. Also, there's an error in the first code...

aerynsAuthor
Known Participant
August 14, 2017

I see, well then that explains why those scripts didn't work. Is there any other way to prevent the "0.00%" from being printed? Or are percentage fields really that limited?