Expand my Community achievements bar.

Nomination window for the Adobe Community Advisor Program, Class of 2025, is now open!

How Do I Limit The Number of Lines In a Text Field?

Avatar

Former Community Member
Does anyone know how to limit the number of lines in a text field?
8 Replies

Avatar

Former Community Member
I don't believe you can. The closest I've seen is a text field with the scrolling property turned off so that when it's full it won't accept more input. But you'd have to guesstimate the proper size for the specific number of lines you want.



Here's some sample script to turn off scrolling in a text field:



var myDoc = event.target;

var f = myDoc.getField("Form[0].SubForm[0].TextField1[0]");

f.doNotScroll = true;



H.

Avatar

Former Community Member
Thanks for the reply Hubert,

And it seems that turning off scrolling will work for my purposes, but I'm completely script illiterate. Where do I add what you've written in the source editor?

Avatar

Former Community Member
Putting it in the initialize event of the text field in question should do the trick. You'd just need to change the string passed into the getField() method to make the hierarchy of your form.



H.

Avatar

Former Community Member
This is sort of a hack but should work.



In the field tab of the object pallette make sure you don't check "allow multiple lines"



This will in effect limit the number of lines to one.

Avatar

Former Community Member
Hi Hubert,



Does the your sample script work with XFA forms? I tried but not able to get it to work.



Thanks.



var myDoc = event.target;

var f = myDoc.getField("Form[0].SubForm[0].TextField1[0]");

f.doNotScroll = true;

Avatar

Former Community Member
Hmm... sorry about that. It looks like it only works with static PDF's saved out of Designer 7 and not dynamic ones.



Are you doing anything in your form that requires it to be a dynamic PDF? (ie: dynamically adding/removing subforms on the client) Otherwise you should be able to use static PDF.



H.

Avatar

Former Community Member
Hi Hubert,



I tried to save the PDF as static and Acrobat 6 compatible static PDF but it still does not work. Can you give me an working example form?



Thank you very much!

Avatar

Former Community Member
Here you go.



H.