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?
Copy link to clipboard
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.
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?
This is incorrect:
fld.value > ""
Change it to:
fld.value != ""
> 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!
You have an error in your code that will cause the field to reset.
fld.value = ""
fld.value == ""
Also, this line is unnecessarily complicated:
var fld = this.getField(event.target.name);
You can replace it with:
var fld = event.target;
Thanks for both of the headsup, Try67! I made the changes you suggested, but the single = sign does appear to work ok???