Field Prompt / Hint

Avatar

Avatar

yosoybyrd

Avatar

yosoybyrd

yosoybyrd

09-09-2011

I am new to LiveCycle and will need all the help I can get...

I am creating a form mostly to be used by myself and others in my company.

I would like to find some way to add a Hint or Prompt in fields that have not been filled in. For example when filling out a contact form I would like for the field for Name to have "Name" in the text box before it is clicked on and "Address" in the address field and so on and so on.

I am sure this can be done I just have not stumbled upon it yet.

Thanks

Accepted Solutions (0)

Answers (9)

Answers (9)

Avatar

Avatar

wesika

Avatar

wesika

wesika

24-06-2015

In the form:ready event you can set the caption text to remain black and normal by adding the following

this.caption.font.fill.color.value = "0,0,0"; //Change the Caption to black

this.caption.font.posture = "normal" //change the caption to normal

Avatar

Avatar

kingphysh

Avatar

kingphysh

kingphysh

10-09-2011

Hi,

OK, what you do is:

==================================

Accesibility Tab / Tool Tip

put your prompt message here (i.e. Name or Address or City...whatever you want as the prompt)

==================================

SOM::initialize - (JavaScript, client)

this.execEvent("exit");
this.format.picture.value = "null{'" + this.assist.toolTip.value + "'}";

// OK, the above fires the exit event on this

// the exit event makes the prompt ghost (gray) and italic

// and then above assigns the assist.toolTip string as the prompt value

==================================

SOM::enter - (JavaScript, client)

this.fontColor = "0,0,0";
this.font.posture = "normal";

// OK, the above changes the field fontColor to "black" and posture to "normal", when you enter the field

==================================

SOM::exit - (JavaScript, client)

if (this.isNull)
{
  this.fontColor = "153,153,153";
  this.font.posture = "italic";
}

// OK, if the field contents isNull when you exit the field, the above changes the fontColor back to "gray" and posture to "italic". This event fires also upon initialization (above, remember?)

==================================

SOM::prePrint - (JavaScript, client)

this.format.picture.value = "";


// OK, changes the prompt message to "" prior to printing.

==================================

SOM::postPrint - (JavaScript, client)

this.format.picture.value = "null{'" + this.assist.toolTip.value + "'}";

// OK, changes the prompt message back to the toolTip after printing.

==================================

And, Bob's your uncle.

I think this is a slick solution--I bet you will think so too!

OK, Cheers,

Stephen

FYI: not my original idea--I read it here somewhere before.

Message was edited by: kingphysh

Avatar

Avatar

Chad_Chelius

Avatar

Chad_Chelius

Chad_Chelius

27-08-2014

This is great. However I'm finding that when I use the javascript code to format the text, it also formats the caption. Is there any way to isolate the formatting to only the text field and not the caption?

Avatar

Avatar

pguerett

Avatar

pguerett

pguerett

13-09-2011

Your script is Javascript and you have the scripteditor set for FormCalc. Change it to Javascript and your script should be fine.

Paul

Avatar

Avatar

yosoybyrd

Avatar

yosoybyrd

yosoybyrd

13-09-2011

When one problem goes away another takes its place.

I moved to a second form I was making, used the same code to have hints for text field, but when I went to view the the form in preview it posts this alert::

(I tried to upload a screen shot but it would not let me)

Script failed (language is formcalc; context is

xfa[0].form1[0].Page1[0].Header[0].Body[0].TextField1[0])

script=

if(this.isNull)

{this.fontColor="153,153,153";

this.font.posture= "normal";}

Error: syntax error near token '{' on line 3, column 1.

Script failed (language is formcalc; context is

xfa[0].form1[0].Page1[0].Header[0].Body[0].TextField2[0])

script=

if(this.isNull)

{this.fontColor="153,153,153";

this.font.posture= "normal";}

etc.

etc.

etc.

Any ideas on what I have done wrong this time?

Avatar

Avatar

yosoybyrd

Avatar

yosoybyrd

yosoybyrd

13-09-2011

After I copied the code in again I have not had the same problem of Designer crashing when I attempted to save or preview it.

Thanks Stephen

Avatar

Avatar

kingphysh

Avatar

kingphysh

kingphysh

12-09-2011

Hi,

OK, when you say crashing, I'm not sure what you mean. Are you talking about

  • Designer crashing when you try to save it after you've created it?
  • Acrobat or Reader crashing when you're using the form, and then trying to save it?
  • Or, are you getting some error in Designer Preview Tab?

These scripts if correctly placed are not the cause of your problem, whatever it is. Double check everything.

  • Is language is set to JavaScript (not FormCalc) on each part?
  • Is the correct event is used on each part?--did you accidently use preSave instead of prePrint?
  • Is the Target Version for the form set correctly in the form properties? Increase the target version to Acrobat and Adobe Reader 8.0 or later for ToolTip support.

JavaScripts can fail, but these won't crash either Designer or Acrobat/Reader. If everything above checks out, then you may have to start over due to corrupt xml.

Good luck!

Stephen


Avatar

Avatar

yosoybyrd

Avatar

yosoybyrd

yosoybyrd

12-09-2011

Thanks

That worked great, except for it is crashing every time I try to save it after I have all the fields set.

Do you know what would cause this?

Avatar

Avatar

whyisthisme

Avatar

whyisthisme

whyisthisme

09-09-2011

You set the default value of the textbox under Object>Value>Default: This will put  whatever text you put in there in the textbox once the form is rendered.