Skip navigation
Currently Being Moderated

Place holders (ghost text) in Form text fields

Apr 26, 2012 8:39 AM

Tags: #acrobat #x #pro #text #field #form #format #options #place #fields #acrobat-forms #formatting_fields #placeholder #holder #ghost #ghosttext

Good morning,

 

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

 

Thanks,

Dale

 
Replies
  • George Johnson
    11,671 posts
    Aug 11, 2002
    Currently Being Moderated
    Apr 26, 2012 9:18 AM   in reply to DaLe Zki

    For #1, use a custom Format script:

     

    if (!event.value) event.value = "Message text goes here.";

     

    The is no mouse over event for text fields.

     
    |
    Mark as:
  • George Johnson
    11,671 posts
    Aug 11, 2002
    Currently Being Moderated
    Apr 26, 2012 9:53 AM   in reply to DaLe Zki

    No other code is needed. As I mentioned, it's a custom Format script, so select the Format tab and select Custom for the format type and you should see where to enter the code.

     
    |
    Mark as:
  • George Johnson
    11,671 posts
    Aug 11, 2002
    Currently Being Moderated
    Apr 26, 2012 11:31 AM   in reply to DaLe Zki

    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;

     
    |
    Mark as:
  • George Johnson
    11,671 posts
    Aug 11, 2002
    Currently Being Moderated
    Apr 26, 2012 12:18 PM   in reply to DaLe Zki

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 26, 2012 2:04 PM   in reply to George Johnson

    George,

     

    You might not be getting your emails but I know that you are out here.  Are you not interested in finishing what you started????

     

    Dan

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points