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

Show Default Value in Text Field Until User Inputs Data

Community Beginner ,
Jul 13, 2018 Jul 13, 2018

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
51.2K
Translate
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
1 ACCEPTED SOLUTION
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.target.value==event.target.defaultValue) {  event.target.value = "";  event.target.textColor = color.black;

}

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

- Paste the following:

// On Blur script:if (event.target.value=="") {   event.target.value = event.target.defaultValue;   event.target.textColor = color.ltGray;}

- Close the properties box

Your fields should now have the default value you set displayed in them. Selecting a text field will "erase" the default value and allow the user to enter their information. Deleting the information will cause the default value to be displayed again.

Thanks for all of the help, guys!

View solution in original post

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

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;

Translate
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
LATEST

Why does you post copies of replies?

Translate
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