Skip to main content
Participant
December 15, 2024
Answered

How to get 1 text field to control the visibility of another

  • December 15, 2024
  • 1 reply
  • 502 views

Hello,


the basics of what I am trying to to is this :

I have a text field called Panel length 1 - i want it so that when a number that is 45 or less is entered into that text field , a second text field called 20ga 1 will become visible - if the number 46 or greater is entered, or there is no number entered at all the text field called Panel length 1 then the text field called 20ga 1 will stay hidden. 

does this make sense or even possible?

thanks in advance for any guidance that can be provided. 

This topic has been closed for replies.
Correct answer Thom Parker

Yes, this is possible and not very difficult. 

Use a validation script on the "Pandl Length 1" field.  

this.getField("20ga 1").display = ((event.value != "") && !isNaN(event.value) && (event.value <= 45))?display.visible:display.hidden;

 

this code tests the entered value for a non-empty entry, that it is a number, and it is less than or equal to 45. 

 

You can read more about hiding and showing fields here:

https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm

 

 

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
December 15, 2024

Yes, this is possible and not very difficult. 

Use a validation script on the "Pandl Length 1" field.  

this.getField("20ga 1").display = ((event.value != "") && !isNaN(event.value) && (event.value <= 45))?display.visible:display.hidden;

 

this code tests the entered value for a non-empty entry, that it is a number, and it is less than or equal to 45. 

 

You can read more about hiding and showing fields here:

https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
December 16, 2024

Thanks so very much!!! This worked beautifully