Skip to main content
Participant
December 28, 2021
Question

Text Box with Lines

  • December 28, 2021
  • 4 replies
  • 7283 views

How can I create a fillable text box with lines?

This topic has been closed for replies.

4 replies

JR Boulay
Community Expert
Community Expert
May 22, 2024

Ex3535 :

// ON FOCUS
if (event.target.value == event.target.defaultValue) {
	event.target.value = "";
	event.target.textColor = color.black;;
}


// ON BLUR
if (event.target.value == "") {
	event.target.value = event.target.defaultValue;
	event.target.textColor = color.ltGray;
}

 

 

Acrobate du PDF, InDesigner et Photoshopographe
Ex3535
Participating Frequently
May 23, 2024

I tried the javascript you gave me above. Sorry I am new to java - what values, if any, do I need to change in order to apply this to my text box?  The background is not filling with white when I type in it. It currently stays transparent.

Am I doing this right?  Thanks so much for your time.

Nesa Nurani
Community Expert
Community Expert
May 24, 2024

I didn't change anything at all. So I'm not sure where to insert the value. I placed the action just as you gave it to me, because I thought it was complete.  I'm sorry for any miscommunication.
I've been playing around with various insertion points and am having a hard time.  I want the text box to be white if they type in it, and transparenet if they just want to print and fill in manually.  Am I asking the wrong questions? I was pretty good at HTML at one time, but it's been a while and java is something I've never attempted to learn well. 

Any advice you could share would be humbly appreciated.


You can use this as 'On Blur' action (remove other scripts):

event.target.fillColor = (event.target.value == "") ? color.transparent : color.white;

 

If the field is empty, fill color will be transparent and if there is value in the field, fill color will be white.

JR Boulay
Community Expert
Community Expert
December 31, 2021

Hi Thom

 

I also have customers like yours.

In this case I leave the background transparent so that the lines are displayed, I place a script in an onFocus Action which changes the background in white as soon as the user starts the input, and a script in an onBlur Action which checks if the field as been filled. If so, it remains white, if not it becomes transparent again.

😉

Acrobate du PDF, InDesigner et Photoshopographe
Thom Parker
Community Expert
Community Expert
December 31, 2021

Nice Solution!  I will keep this in mind. Thanks JR 🙂

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
JR Boulay
Community Expert
Community Expert
December 29, 2021

The underlines date from paper forms, you have to change the paradigm.

Users do not need those lines because it is not possible to write crookedly in a digital form, so just use a color (white) to hide lines that are on the layout.

🙂

Acrobate du PDF, InDesigner et Photoshopographe
Thom Parker
Community Expert
Community Expert
December 29, 2021

Hi JR,

I like your way of thinking!! Unfortunately I run into this all the time. The paper mindset will be with us for a while. Customers insist on having lines for multiline inputs. We need to change this to using a box for multiline.   

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
December 28, 2021

Explain what you mean by "create a fillable text box with lines"

 

 

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

I want to create a text box that has lines in it example:

____________________________________________

____________________________________________

____________________________________________

So that when you type it the words are above the line like on a piece of paper.

Thom Parker
Community Expert
Community Expert
December 28, 2021

The Appearance tab on the Form Field Properties window provides an option for an "Underline" on the field. I do not find this option very useful. Espcially since its only good for single line fields. 

It is much better to add the lines to the PDF Page, then place the form fields over the lines. 

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often