Is there a way to add instructional text to my text field that will disappear when clicked?

I want to add some text into a form field to instruct respondents how to fill out the field and have the text disappear when the respondent clicks the field. Is this possible?


Patty Friesen


2 Answers

Voted Best Answer

I use a custom Format script for this. This way, the field value is never set to the instructional text (important for required fields) and it doesn't print, which is useful for forms that may need to be printed and filled-in by hand:

// Custom Format script for text field

if (!event.value) {

event.value = "Instructional text goes here";

event.target.display = display.noPrint;

} else {

event.target.display = display.visible;

}


By George Johnson   

Here's my way of doing it. Others might prefer a different method...

Set the field's default value to the text you want to display by default and then apply the following code to the field's On Focus and On Blur events, resp.:

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

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

When the user clicks into the field, the default value will disappear and the field will be blank. If they don't enter anything (or delete what was there) and then exit the field, the default value will be shown once more.

The third line of code in each block is an optional feature that will change the field's text color to a light gray when it shows the default value or to black when an actual value is filled-in by the user.

.


Visit my custom-made PDF scripts website: http://try67.blogspot.com
Contact me personally: try6767@gmail.com


Gilad D (try67)   


Please specify a reason: