• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Is there a way to format instructional text to my text field that disappears when clicked?

Community Beginner ,
Jan 11, 2018 Jan 11, 2018

Copy link to clipboard

Copied

I have the prompt text figured out using this script taken from this forum: Is there a way to add instructional text to my text field that will disappear when clicked? (PDF For...

// Custom Format script for text field

if (!event.value) {

event.value = "Instructional text goes here";

event.target.display = display.noPrint;

} else {

event.target.display = display.visible;

}

Is their a way to change the prompt text's size and make it different from the type size I have set for them to fill out in the form. I want the type size of the prompt to be smaller than what size they use to fill it out.

TOPICS
PDF forms

Views

15.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 11, 2018 Jan 11, 2018

Why yes there is, and your code is already setup for adding it.  The "display" is a property of the text field object, and it is being set one way for the help text, and another way when the user enters the text. The text size is also a property of the text field object and it can be set in the same way.

// Custom Format script for text field

if (!event.value) {

event.value = "Instructional text goes here";

event.target.display = display.noPrint;

event.target.textSize = 12;

} else {

event.target.displ

...

Votes

Translate

Translate
Community Expert ,
Jan 11, 2018 Jan 11, 2018

Copy link to clipboard

Copied

Why yes there is, and your code is already setup for adding it.  The "display" is a property of the text field object, and it is being set one way for the help text, and another way when the user enters the text. The text size is also a property of the text field object and it can be set in the same way.

// Custom Format script for text field

if (!event.value) {

event.value = "Instructional text goes here";

event.target.display = display.noPrint;

event.target.textSize = 12;

} else {

event.target.display = display.visible;

event.target.textSize = 9;

}

You could also set the size on the keystroke event, or the OnFocus event, to capture the moment the user starts typing in the field.

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 11, 2018 Jan 11, 2018

Copy link to clipboard

Copied

Hey Thom,

You could also set the size on the keystroke event, or the OnFocus event, to capture the moment the user starts typing in the field. How would I do that? I'm very new to this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2018 Jan 15, 2018

Copy link to clipboard

Copied

Add this to the custom Keystroke script on the field

if(!event.willCommit)

     event.target.textSize = 9;

It sets the text size to 9 at the moment the user types the first character in the field

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 15, 2018 Jan 15, 2018

Copy link to clipboard

Copied

Thank you so much Thom! Do you have any books or websites you could recommend where I could learn more creating advanced forms? It was very hard to search for my answer. Thanks again for your help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2018 Jan 15, 2018

Copy link to clipboard

Copied

Why Yes I do   pdfscripting.com

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

How do I add this custom action to the text field. nowhere in the actions box, under text field properties is a place to add something custom. It just offers a set list of items. Please advise.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

You must use a text field, not a drop-down.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

? It's already a text field. I'm trying to make it have instructional text that disappears once the user types in content, much like the title of this conversation, but i have no way of knowing how to apply the custom script to the text field thru > Properties > action ... ?

Apparentlt there's another way.  Please advise.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

Some folks say to use the Text Field Properties>Actions tab, but the Format tab is the one where you can apply a Custom script. Why is that so hidden in all the conversations? Vague? It certinly wasn't as simple as it should have been.

Thanks for your time though.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 30, 2021 Oct 30, 2021

Copy link to clipboard

Copied

The Actions tab on the field properties dialog provides a list of built-in actions for the mouse/cursor events. One of these "Actions" is "Run a JavaScript". So you can easily add a custom script to one of these events. 

 

However, if you will re-read the original qestion and answer, you'll see the provided code is specifically for a Custom Formatting Script, and the follow on comments provide alternate code for using a Custom Keystroke Script. A later comment even shows a screen shot of the field properties dialog and the location where the code is entered in the Format Tab.  There is no place in this thread where anyone suggest entering the code on the Actions tab.   

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

Maybe I misunderstood what you meant by "It just offers a set list of items".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

Using this script. Is there a way to add multi-line instructions eg:

event.value = "Instruction example one"

next line "Instruction example two"

 

Thank you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

Yes, in field properties under 'Options' tab, select 'Multiline' and use '\n' for new line in text something like this:

event.value = "Instructional text goes here\nText for second line goes here\nText for third line...etc";

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 23, 2023 May 23, 2023

Copy link to clipboard

Copied

Thank you! that worked perfectly

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 07, 2023 Sep 07, 2023

Copy link to clipboard

Copied

LATEST

Hello, is there a way to change the instructional text? I would like to make it a lighter color or red.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2020 Sep 09, 2020

Copy link to clipboard

Copied

Thanks. Now how do I apply this java script to all my text fields in one step? I want to avoid having to go to all my 300 comment boxes, open them and insert instructional text to my text field .

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2020 Sep 09, 2020

Copy link to clipboard

Copied

You want the same instructions for all text fields?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2020 Sep 09, 2020

Copy link to clipboard

Copied

Yes for all text fields

 

I am using the script below to add instructional text to my text field that will disappear when clicked. But the script is only valid for one box.


Now how do I apply this java script to all my text fields in one step? I want to avoid having to go to all my 300 comment boxes, open them and insert instructional text to my text field.


if (!event.value) {
event.value = "Instructional text goes here";
event.target.display = display.noPrint;
} else {
event.target.display = display.visible;
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2020 Sep 09, 2020

Copy link to clipboard

Copied

Note: Comment boxes are not form fields.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2020 Sep 09, 2020

Copy link to clipboard

Copied

I don't think I used "form fields" in my question. I wrote "text field" 

 

Are you saying I cannot do it? Or I can?

 

I want the same instructions for all text fields.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2020 Sep 09, 2020

Copy link to clipboard

Copied

form text fields or comment text fields?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2020 Sep 09, 2020

Copy link to clipboard

Copied

It is a text field where users can insert their comments. 

 

Tara5F91_0-1599663459684.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2020 Sep 09, 2020

Copy link to clipboard

Copied

This is a form text field.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2020 Sep 09, 2020

Copy link to clipboard

Copied

So is that a "yes - it can be done" Or "No - it cannot be done"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines