Copy link to clipboard
Copied
Hello.
I am not really good with javascrip. How can I solve that I like to make a form text field only visible if the previous form text field is filled. Thanks
Copy link to clipboard
Copied
It's possible but you will have to enter script into each field.
You will use scripts as 'custom keystroke script'.
Go to field properties -> format tab and select 'custom' then 'custom keystroke script' (when you enter script it will disappear but it will still work).
for row1:
put this in "ItemName1" field:
this.getField("MaterialNumber1").display = AFMergeChange(event).length != 0 ? display.visible : display.hidden;
put this in "MaterialNumber1" field:
this.getField("ItemQuantity1").display = AFMergeChange(event).length != 0 ? display.visible : display.hidden;
Repeat for other rows by changing field names in script.
Copy link to clipboard
Copied
Since you didn't provide field names lets say you have "Field1" and "Field2", to hide/show "Field2" depending on "Field1" value, as validation script of "Field1" use this:
this.getField("Field2").display = event.value == "" ? display.hidden : display.visible;
Copy link to clipboard
Copied
Thank you Nena. Can It be triggered by the start of the typing and dynamic (I mean If i clear the first field in the case the second field become invisible)? There are 3 colomns and 15 rows. Only the first row is visible and i like to make visible every colomns in the following rows after start the typing in the previous. The Field names ItemName1-ItemName15/SKU1-SKU15/Quantity1-Quantity15 and the order in the ItemName->SKU->Quantity. I know the Quantity in the row validate the ItemName in the next row. With the above script it is working but isn't hide the next field if I empty the previous (I like to do it in the case both are empty).
Copy link to clipboard
Copied
It's possible but you will have to enter script into each field.
You will use scripts as 'custom keystroke script'.
Go to field properties -> format tab and select 'custom' then 'custom keystroke script' (when you enter script it will disappear but it will still work).
for row1:
put this in "ItemName1" field:
this.getField("MaterialNumber1").display = AFMergeChange(event).length != 0 ? display.visible : display.hidden;
put this in "MaterialNumber1" field:
this.getField("ItemQuantity1").display = AFMergeChange(event).length != 0 ? display.visible : display.hidden;
Repeat for other rows by changing field names in script.
Copy link to clipboard
Copied
Hello Nesa. I tried it out and worked perfectly. I moved forward and added it to the last in the row with the name of the first field in the next row. This way only the first row visible and the rest is appear as required. Thank you a lot.
Copy link to clipboard
Copied
You can read all about hiding and showing fields in this article.
https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
This is what I have.

