I have a default entry in my form field; however, I want the default entry to clear when I select the field.

I have several text fields in my Adobe Acrobat Pro-X. I have placed default text in the fields to assist the user. I want the default text to clear when the field is selected.

Ralph Hoover

5 Answers

Voted Best Answer

That can be accomplished with a few simple scripts (this is for PDF forms, aka Acroforms):

In the onFocus action, add this JavaScript:

if (event.target.value == event.target.defaultValue) {
event.target.value = "" ;

and in the onBlur action, add this JavaScript:

if (event.value == "") {
event.target.value = event.target.defaultValue ;

This will blank out the default value, but it will not change anything if there is another value in the field.

Hope this can elp.

Max Wyss.

By Max Wyss   

Did you create your form in Acrobat or LiveCycle Designer. The solution is different for each forms technology.

Thom Parker
The source for PDF Scripting Info pdfscripting.com

The Acrobat JavaScript Reference, Use it Early and Often

The most important JavaScript Development tool in Acrobat
The Console Window (Video tutorial)
The Console Window(article)

Having trouble, Why Doesn't my Script Work

Thom Parker   

Here's another approach that will work for an acroform: http://forums.adobe.com/message/4439892

George Johnson   

I think George has the best AcroForm Solution. Using the Format event keeps you from mucking about with the real field value, and it works in all situtions from the user entering data to automatic entry.

Unfortunately, LiveCycle forms don't have such a nice format event. In that technology you'll need to use the "enter" event to clear the default.

Thom Parker   

Thanks Max
That worked like a champ.

Ralph Hoover   

Please specify a reason: