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

Show Default Value in Text Field Until User Inputs Data

Community Beginner ,
Jul 13, 2018 Jul 13, 2018

Copy link to clipboard

Copied

Okay, so... I'm trying to figure out how to have default text show in a form field/text field until the user clicks on it and inputs their own data. I don't want labels, I just want default values to be displayed in the fields.

I've read through so many forums, and they all have code along these lines:

if (event.target.value=="") {

   event.target.value = event.target.defaultValue;

   event.target.textColor = color.ltGray;

}

I've tried every suggestion I found, but it still doesn't work.

Using Acrobat XI Pro.

TOPICS
PDF forms

Views

43.9K

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 Beginner , Jul 16, 2018 Jul 16, 2018

Finally got it. I was trying to use the scripts I've seen for the entire form. I didn't know you had to set actions for the form fields.

I'm going to break it down Barney style for the new users (like myself).

- Add a text field to your form

- View the text field's properties

- Under the Options tab, enter the default text that you want to be displayed

- Under the actions tab, select trigger On Focus, select action Run a JavaScript, click Add...

- Paste the following:

// On Focus script:
if (event.targe

...

Votes

Translate

Translate
New Here ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

Finally got it. I was trying to use the scripts I've seen for the entire form. I didn't know you had to set actions for the form fields.

I'm going to break it down for the new users (like myself).

- Add a text field to your form

- View the text field's properties

- Under the Options tab, enter the default text that you want to be displayed

- Under the actions tab, select trigger On Focus, select action Run a JavaScript, click Add...

- Paste the following:

if(event.target.value==event.target.defaultValue)event.target.value="";

 

- Same steps but now under On Blur instead of On Focus, select action Run a JavaScript, click Add...

- Paste the following:

if(event.target.value=="")event.target.value=event.target.defaultValue;

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 ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

LATEST

Why does you post copies of replies?

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