Skip to main content
Inspiring
April 14, 2022
Answered

How to create multi-line text box on top of printed lines for writing?

  • April 14, 2022
  • 1 reply
  • 2153 views

When I create a form, I have a large area of multi-line text for people to fill the form on their computer. But when they print the form, I want to have lines appear for them to write on. But if someone types into the form with their computer, the lines of text do not correspond with the lines that I have drawn for writing into. Is there a way to have the lines not appear if the person fills the form with their computer, but print if they don't fill in the text box from their computer?

This topic has been closed for replies.
Correct answer Terry Wysocki

> Is there any way to have the script run more interactively as soon as the first character is typed?

You can use a keystroke event, but the field's appearance will not update until you exit it.

 


Ok, here's my final solution! I created two actions. OnFocus I have this script:

this.getField(event.target.name).fillColor = color.white;

Which hides the lines as soon as a cursor comes into the field.

 

Then I examine the contents when exiting and set the background with an OnBlur action:

var fld = this.getField(event.target.name);
fld.fillColor = fld.value = "" ? ["T"] : color.white;

If nothing was entered, the text lines show, otherwise the box has a white background.

THANKS for all your help, Try67. I'm learning a lot!

1 reply

try67
Community Expert
Community Expert
April 14, 2022

You have to manually (and carefully) adjust the size of the font and location of the field for them to match. It's not an easy task. But there's no need for the fields if the form is filled digitally, so you can set the field as having a white fill color and as visible on the screen, but change it to be hidden when printed, if it's empty.

This requires using a script, though.

Inspiring
April 14, 2022

Thanks for the quick answer! I suspected it wasn't going to be easy. I found a scripting tutorial at https://www.youtube.com/watch?v=wySx6rhK-E4 so it's back to school for me! (I'll be back!)

Inspiring
April 14, 2022

Ok, I'm back (quick learner). Here's the script I came up with:

var fld = this.getField("mission");
fld.fillColor = fld.value > "" ? ["T"] : color.white;

This makes the background color white (blocking the background lines) if anything is entered in the field. BUT, it happens when I exit the field. As I type characters, I see them overlaying the lines (inaccurately).

Is there any way to have the script run more interactively as soon as the first character is typed?