Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Script or Option to make text field invisible if user starts typing in another text field

Avatar

Former Community Member

My form shows underlines in an area where a user can hand write notes. I would like the option to add notes electronically by inserting a text field over the other text field. This is done easily however, when the user types text, the text does not line up to the UNDERLINES found in the text field underneath.

Is there any way that I can hide the text fields containing the UNDERLINES as soon as a user starts typing? And if the user does not type any text, the UNDERLINES will show in the printed form.

Sorry if this is confusing, but any help is appreciated!

Thanks...

-JoeF

8 Replies

Avatar

Level 5

Hi,

Could you not just set the Textfield with the underlines to visible ( print only) to begin and then after (or if) the user has entered a value in the other textfield change the status of the textfield with the underlines to hidden.

This would mean if the user enters data the lines never show, if they do not enter data the lines will show.

Regards

Malcolm

Avatar

Level 2

How would I apply the HIDDEN feature to the text containing only the UNDERLINES?

I set the text field containing th UNDERLINES to VISIBLE(PRINT ONLY) as you suggested, but if a user starts typing in the text field(Which overlaps the UNDERLINES text field), BOTH the underlines and user text print, and nothing lines up. Is there a way to set the UNDERLINES text field to hidden on the fly(As a user starts typing in the text field overlapping it)?

Thanks...

Avatar

Level 2

You set me on the right path and I did some research. Got 50% of the answer. When I insert a FORMCALC script in the CHANGE action of the TEXT FIELD overlayed on top of the UNDERLINE text fields, it works as I wanted it to work. Here's the script:

topmostSubform.Page1.NOTES_1::change - (FormCalc, client)

UNDLN_1.presence = "invisible"

UNDLN_2.presence = "invisible"

UNDLN_3.presence = "invisible"

However; after saving and opening the PDF file back up, the UNDERLINES appear in the area I typed my text.

When I click in the area and add anything, the lines disappear(Which makes sense since it's configured under the change action).

How can I make the PRESENCE value sticky? After saving the file, the UNDERLINES don't come back and stay invisible?

Thanks so far!!!!

-JoeF

However; after saving and opening the PDF file back up, the UNDERLINES appear in the area I typed my text.

When I click in the area and add anything, the lines disappear(Which makes sense since it's configured under the change action).

How can I make the PRESENCE value sticky? After saving the file, the UNDERLINES don't come back and stay invisible?

Thanks so far!!!!

-JoeF

Avatar

Level 5

Hi ,

You could add a script something like this to the initialise of the text field with the underscores

// start script

if  (TextField1.value <> "" ) then

     TextField2.presence = "hidden"

endif

// end script

TextField1 is the text field into which the text is entered

TextField2 is the text field with the underscores

Hope this helps

Regards

Malcolm

Avatar

Level 2

I think this is exactly what I needed....I will try it shortly. Thank you!

Avatar

Level 2

I tried but there's a problem. When I open up the PDF, the TextField2(Underlines) is hidden before anything is typed. There must be a value already in TextField1?

// start script

if

(NOTES_1.value <> "" ) then

     UNDLN_1.presence = "hidden"

     UNDLN_2.presence = "hidden"

     UNDLN_3.presence = "hidden"

endif

// end script

Avatar

Level 5

HI,

The only way to find that is to check that there is nothing in the default value entry for the field ( including a space) as this would be returned as a value and therefore the code would not show the field.

Other than that it is just a case of working through to make sure that you are checking the correct field and that there are no other scritps that are modifying the value of that field.

Regards

Malcolm

Avatar

Level 2

Thank you for your suggestions...

I just can't figure this out. There's no default value. I even inserted a new text field with an initialize script showing the value of "NOTES_1", but nothing shows up there.

I had to change all my TEXT objects(That contain the UNDERSCORE) to TEXT FIELD object types in order to get a script inserted. Now it's giving me "Mispelled Caption" warnings, which I don't care about because it's only underscores, but maybe this has something to do with it?