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

How to make a form field with a border and background only print if that field has been filled in

New Here ,
Jul 17, 2025 Jul 17, 2025

Hi everyone,

I'm having a bit of difficulty with form fields.

Basically I have some product labels, some of which require to show a "UN" number and some which don't.

The client wants to be able to add the UN number themselves to the products which need it, and if they don't need it then this field  including the background colour and the border should not print.

 

Image1.png

 

The UN number, if it shows, needs to appear in an orange box with a black border. So if they fill in this field when they print it out it will look like this:

 

Image4.png

 
So far I have done all of the above and it is fine and works.

The problem is that if the field is NOT filled in because it has been purposely left blank I want it to not print at all so it looks like this:

 

Image5.png

 

But it doesn't. It prints like this:

 

Image6.jpg

 
How do I make the box NOT print if the form field remains empty?

Thanks in advance for any help.
Richard

TOPICS
How to , JavaScript , PDF forms
266
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
Community Expert ,
Jul 17, 2025 Jul 17, 2025

Enter the following custom calculation script in the field:

if(event.value)
{event.target.display=display.visible}
else
{event.target.display=display.noPrint}
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 18, 2025 Jul 18, 2025

Sorry, that doesn't work. The blank orange box with the black border still appears on the printed file the same as before.

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
Community Expert ,
Jul 18, 2025 Jul 18, 2025
LATEST

Where did you place the script?

If you can't make it work, please share the file with us.

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