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:
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.
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 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!
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;
Copy link to clipboard
Copied
Why does you post copies of replies?


-
- 1
- 2