Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Limit TextField to specifc number of lines

Avatar

Level 1

Hi,

First of all the limit to character number is not enough for my case. I would like to make sure that the user won't be able to enter more than 3 lines of text. In addition the field can be either filled in directly or using two other fields + button (as you can see below).

I managed to limit the amount of text that user can enter into the field by using the following two lines of codes:

Initialize:
this.maxH = "18mm"; //3 lines

Full:

xfa.event.change = "";

and checking those two checkboxes in the "Object/Field":

[x] Allow Multiple Lines

[x] Limit Lenght to Visible Area.

and in the "Layout" under height:
"9mm" / Expand to fit.

This works fine until I use a button that populates this field with content from another two fields:

Script in the Click event of a button:

var something = TextField2.rawValue + TextField3.rawValue;

TextField1.rawValue += something;

The above two lines "do not care" about the script of TextField1 in the Full event.

Is there a way to check if the "TextField1.rawValue += something;" will cause the TextField1 to overset the text and display an alert instead?

The LCD version i'm using is: 9.0.0.2.20101008.1.734229

Many thanks for your help

3 Replies

Avatar

Level 10

Hi,

you can combine several object properties to create a text field, with a min/max size that will grow in a limited way.

Paste this code directly into the XML source.

<field name="textField" y="1.15mm" x="1.15mm" w="66.675mm" minH="9mm" maxH="18mm">

            <ui>

               <textEdit multiLine="1" hScrollPolicy="off" vScrollPolicy="off">

                  <border>

                     <edge stroke="lowered"/>

                  </border>

                  <margin/>

               </textEdit>

            </ui>

            <font typeface="Arial"/>

            <margin topInset="0mm" bottomInset="0mm" leftInset="0mm" rightInset="0mm"/>

            <para vAlign="middle"/>

            <caption reserve="25mm">

               <para vAlign="middle"/>

               <value>

                  <text>Text Field</text>

               </value>

            </caption>

         </field>

You'll see a warning in Designer that the limit to visible area feature won't work, but it works for manual input.

For inputs by scripting the overflowing text won't be visible and indicated by the plus sign in the text fields end.

Avatar

Level 1

Thanks a lot for your explanation.

Do you maybe know some property or something else that I could check on click event of a button that will chek if the field is full before adding any new text to it?

Regards,
Bartosz

Avatar

Level 10

I don't think so.

The full event only fires if the field has focus and is changed by the user not when it's populated by a script.