I am looking for a acrojs script to display a Place Holder or "ghost test" in a Form's text field.
1) When user of the form puts cursor in the Form field,
the Place Holder text is removed.
When the cursor is moved out of the field,
and should the field remain empty, the Place Holder text returns.
2) same as above but use MouseOver, MouseOut.
Using Acrobat X Pro
I really appreciate your quick reply.
The text's field name is "name".
I have a validation script within it's properties that is working well.
Before I use the above script... my novice senses tell be there is
other surrounding code required.
For clarity and my documentation;
Where will I place this code (i.e. using the text field properties / Script editor.. if so where in said script)?
What other surrounding code is required?
Thanks so much for your time today...
Prefect, thank you.
Noted: use the Format tab, not the Actions tab within the Text field's properties.
Would specific formatting of this place holder ( color / size) be another
custom Format script or can a reference be found in the JS for Acrobat API manual?
I used the on Focus / on Blur events in the Action Tabs using these scripts (noted below),
but soon realized it was Form Text Field specific and did not effect the "place holder" attributes specifically.
// for On Focus event
event.target.textColor = color.black;
// for On Blur event
event.target.textColor = color.ltGray;
I welcome you thoughts, resources or coding snippets.....
Again - Thanks !
You can change the text color in the on Focus event, but the change won't take effect until the field loses the focus. So if it starts off grey and the code changes it to black, the text that the user types will be grey, until the field loses the focus and it changes to black.
A different approach is to place what you're calling the placeholder text on the page as regular page contents and make it grey. You can then use a custom Validate script that controls the background color of the text field, something like:
// Custom Validate script
event.target.fillColor = event.value ? color.white : color.transparent;
In addition to the following On Focus script:
// On Focus script for text field
event.target.fillColor = color.white;
Just a quick not, your tip in post #5 is very unique.
It reminds me of "layering" in Photoshop.
In this case the Form Text Field is in front of typed text field.
Your script then plays witht the Form field's background.....
Very Nice !!
I'm glad you got what I meant, because I forgot to add that you're supposed to place the text field over the placeholder text.
If you don't want the placeholder text to print, you can either place it on a non-printing layer, or place it in a non-printing, read-only text field, and place the active field on top. For stacked fields, the tab order determines the z-order and thus which one is on top.