Hide Ruled Lines When Text Is Entered in an Acrobat PDF Form
Question details
Create a PDF form that shows ruled lines when a text field is empty and hides them when text is entered.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A form needs lines for handwritten answers on a blank printout and a clear background for digitally entered answers.
- Observed behavior
- The desired form shows lines through an empty field and covers them with a white field background after text is entered.
Open the PDF in an Acrobat version that can edit form fields, and make sure the ruled lines are already part of the page. Test the finished form in a PDF viewer that supports Acrobat form JavaScript.
Use a Validation Script to Change the Text Field Background
Use this method to switch the field background between transparent and white when the user commits an entry.
The text field sits over the ruled lines. A transparent fill reveals the lines when the field is empty; a white fill covers them when the field contains text.
In Acrobat, open the PDF and select All tools > Prepare a form. Add a text field over the ruled lines, or select an existing field and resize it to cover them.
Right-click the text field, select Properties, and open Appearance. Set the fill color to transparent and choose an appropriate text color. On the Options tab, enable Multi-line if the answer needs more than one line.
In the field Properties dialog, open the Validate tab, select Run custom validation script, and click Edit. Enter: event.target.fillColor = event.value !== "" ? color.white : color.transparent;
Close the dialogs, save the PDF, and exit form editing. Enter text and press Tab or click another field to commit it; the background should turn white. Clear the field and commit it again to reveal the lines.

Cover Ruled Lines Manually in WPS PDF
For a one-time filled copy, use WPS PDF annotation tools to cover the lines with a white shape and add your answer. This is a manual workaround and does not create Acrobat's automatic field behavior.
- 1. Open the form: Open WPS Office, select Open, and choose the PDF form.
- 2. Cover the lines: In WPS PDF, open the annotation or Comment tools and draw a rectangle over the lines. Set its fill to opaque white and remove the border if those options are available.
- 3. Add your answer: Select the text box annotation tool and place a text box over the white rectangle. Enter and format your answer.
- 4. Save the filled copy: Use File > Save As to save the annotated PDF, then open the saved copy to check that the text and covered lines appear as intended.

Frequently Asked Questions
Why do the lines still show after I type?
Press Tab or click outside the field to commit the value and trigger validation. Also check the field's Validate tab for the script and test in Acrobat or Acrobat Reader with JavaScript enabled.
Will the lines return if I delete the answer?
Yes. Clear the field and press Tab or click another field. The validation script sets the fill to transparent when the committed value is empty.
Can I use this for a multiline answer?
Yes. In Prepare a form, open the text field's Properties > Options and enable Multi-line. Make the field large enough to cover the ruled area.
Will the blank form print with the ruled lines?
The lines should print when they are part of the PDF page and the empty field has a transparent fill. Print a test page from your intended viewer to confirm.




