Skip navigation
Currently Being Moderated

How to create disappearing instruction text in fields

Jun 28, 2012 8:36 AM

Tags: #text #forms #vanishing

Hello, all.  I'm a noob hoping to get a little help creating a form.

 

My idea is to have instruction text in a form field that tells the user what sort of information to include, but then have that text disappear when the user goes to fill out the form (either on click, or typing the first character, or whatever).  I'm pretty sure this can be done with javascript, but as a noob, I haven't a clue how to implement such a solution.  Any clues/help would be much appreciated.

 

Thanks in advance,

 

/TW

 
Replies
  • Currently Being Moderated
    Jun 28, 2012 8:53 AM   in reply to TomWedell

    Here's what I have used in the past:

     

    var message = 'Please enter your name here:'

    if (event.value == '') {

        event.target.display = display.noPrint

        event.value = message

    } else {

        event.target.display = display.visible

    }

     

    Add this to the 'Custom Format Script' for the field you want to display, and change the message to fit your needs.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 28, 2012 1:19 PM   in reply to TomWedell

    I also included the code which set the field's 'Display' property. This prevents the default instructions from printing.

     

    If you want those instructions to print, then you can remove those two lines.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 10, 2012 2:47 PM   in reply to MarkWalsh

    Hi Mark,

     

    I love how this works, but how can I change the font size and color or italicize the message?

     

    Melanie

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 11, 2012 5:18 AM   in reply to govrellic

    Yes, but you cannot reset the font when the user needs to edit the field - the font will remain the same as it was last formatted until the user exits the field. (i.e. if the text was last formatted to be red or bold or italic, it will remain that way while the user edits the text)

     

    See this thread: http://forums.adobe.com/thread/1031780

     
    |
    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