Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Ghost & Default Text

New Here ,
Feb 09, 2016 Feb 09, 2016

I want to have ghost text (instructions) and default text (necessary language) on the same form field.  Is this possible?

TOPICS
Acrobat SDK and JavaScript , Windows
3.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 10, 2016 Feb 10, 2016

Change that format script to:

// Custom Format script for text field

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

    event.value = "Text goes here";

    event.target.display = display.noPrint;

} else {

    event.target.display = display.visible;

}

Set the default value of the field to "Please provide ", and you might want to add the following custom Validate script:

if (!event.value) {

    event.value = event.target.defaultValue;

}

Translate
Adobe Employee ,
Feb 10, 2016 Feb 10, 2016

Hi juliaf71725967,

Would request you to please elaborate you workflow,what changes  you are looking for in the field information so that we can help you more effectively.

Regards,

Yatharth 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 10, 2016 Feb 10, 2016

I have a JavaScript written to allow "Ghost Text" or placeholder text that disappears in the field when the user completes it.  The placeholder text is instructions, for example "Write Out Number." 

However, I want to also allow Default text to appear when the user attempts to fill out the form (upon selection of the field, the ghost text disappears but the default text appears).  The default text is required information, such as "Please provide" xxxx.  The user is required to fill out the xxx with the written number, but the "Please provide" is required by the person accepting the form.

Tooltips are not viable, as the users are not familiar with hovering.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 10, 2016 Feb 10, 2016

You will also have to consider the formatting of the field because fields with a format like number, date or time cannot accept alphabetical characters so gray instructions could not appear in the field. If one makes all fields with a format of "None" then you need to use custom scripting to perform all validation for entered data like dates and numbers. And a lot of this work will need to be redone when summing a number of fields.

You might want to first see how a simple form works and then work on adding the more advanced features.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 10, 2016 Feb 10, 2016

Not relevant.  All fields are formatted "None" because the filler is not required to be a number/date/etc.  It is all text. 

This is an upgrade to a simple form.  The users require more instruction to fill it out correctly, however, those instructions cannot be visible.  Unfortunately, the Tooltip function was not to their liking.

The placeholder text is a hit, however, they still want the default text to prompt them how to fill out the field correctly after receiving instruction.  I just wondered if this was possible? 

When I try to enter the default text, it overrides my script for the placeholder text.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 10, 2016 Feb 10, 2016

What script are you using? It can probably be altered to allow what you want.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 10, 2016 Feb 10, 2016

// Custom Format script for text field

if (!event.value) {

event.value = "Text goes here";

event.target.display = display.noPrint;

} else {

event.target.display = display.visible;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 10, 2016 Feb 10, 2016

Change that format script to:

// Custom Format script for text field

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

    event.value = "Text goes here";

    event.target.display = display.noPrint;

} else {

    event.target.display = display.visible;

}

Set the default value of the field to "Please provide ", and you might want to add the following custom Validate script:

if (!event.value) {

    event.value = event.target.defaultValue;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 10, 2016 Feb 10, 2016

Thank you so much! That worked!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 16, 2016 Mar 16, 2016

Is there a way to change the formatting on this ghost text javascript? For instance, I would like to make it very light gray and italic so that it's clear the field hasn't been filled in.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2016 Mar 16, 2016

You can the field's text color using the fields fontColor and setting to the appropriate color array value. You can change the font using the textFont property with the correct name for the font and affect.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2017 Jan 19, 2017

Would you be able to tell me how to change the font size?

I have this script working for OnFocus, and just want to change the font to 9 pt when the user fills in the field.

// On Focus script:

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

    event.target.value = "";

    event.target.textColor = color.black;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2017 Jan 19, 2017

Add this line to the code:

event.target.textSize = 9;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2017 Jan 19, 2017
LATEST

Thank you! That worked.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 10, 2016 Feb 10, 2016

You can use the property Tooltip for the instructions.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines