Expand my Community achievements bar.

Ghost text in a numeric field.

Avatar

Level 1

Hello,

I'm trying to format a numeric field, but one that has a ghost instructional text in it. I've found this wonderful link that provides script to accomplish the ghost text (which I've used successfull throughout the form) ...at this link: http://cookbooks.adobe.com/post_Adding_Ghost_Text_to_LiveCycle_Designer_form-18436.html

..But this scripting seems to override the $ZZZ,ZZZ,ZZ9.99 format that I'd like to use. Or if I pull out the scripting, format will work, but ghost text will not show. It seems that the scripting from that link above is conflicting/overwriting the "picture" variable of the <format>...</format> command. And I don't know enough about Javascript to know how to work around/with it.

(In short, I'm trying to elicit a user-entered list of dollar amounts for "debts owned" in that form area with ghost text that initially reads "Amount"; but one that will follow a consistent formatted output.)

..And if I successfully get the ability to do this one, the next column will attempt to do the same thing for "Interest Rate" formatted entries -- although I suspect that those two codes might be similar.


Thanks!

5 Replies

Avatar

Level 10

I don't think it's going to work as you can't put text in a numeric field.

Avatar

Level 1

Thanks Jono, Actually the "ghosting" does work, probably because it's hard-coding behind the scenes, before it hits the verification-for-numeric. But I don't know enough about coding and/or the pattern portion of the "picture" field to keep them from stepping on each other.

Avatar

Level 10

Oh I see. Not sure if this helps but you can use format.picture.value to set the patterns:

FieldName.format.picture.value = "num.currency{}";

FieldName.format.picture.value = "num{(zz9.zz'%')}";

So you might be able to force it back to what you want.

I've used that ghosting script once before but can't remember much about it. BR001 here on the forums wrote it so maybe he'll see the post.

Avatar

Level 10

Hi,

I can see my script would cause a problem with your format picture, and still am not sure of the best way to solve it but here is one way. 

In the patterns dialog for your numeric field add a pattern like null{'Amount'}|num{$ZZZ,ZZZ,ZZ9.99}. (You can just cut and paste this sample or add your format pattern and select Allow Empty and type in the text you need (like "Amount"),

Then make the following changes to the script.

form1.#subform[0].#subform[1].NumericField1::prePrint - (JavaScript, client)

this.format.picture.value = this.format.picture.value.replace(/null\{.*?\}/, "");

form1.#subform[0].#subform[1].NumericField1::postPrint - (JavaScript, client)

this.format.nodes.remove(this.format.getElement('picture'));

form1.#subform[0].#subform[1].NumericField1::ready:form - (JavaScript, client)

this.execEvent("exit");

So now because you have added the format pattern in the Designer UI you can remove the second line of the ready:form script.  The prePrint and postPrint are all about removing the ghost text if the user decides to print the form, so you may not need that code at all.  In the code above the prePrint code will remove the null{} clause from the pattern and the postPrint code will remove the pattern element from the Form DOM, which means it will revert back to the value that is in the Template DOM, which means this code is doesn't need to know the pattern you used in the Designer UI.

Hope that helps

Bruce