Skip to main content
Participant
May 17, 2023
Question

How to have instructions like "Type your answer here" in a cell until populated with the answer

  • May 17, 2023
  • 2 replies
  • 1177 views

How do I have a text field that shows something like "answer here" until someone types in that field and the "answer here" disappears. Is this possible? Make sense?

This topic has been closed for replies.

2 replies

Participant
May 22, 2023

I am having problems making one of these custom format script work.

 

I should go into Properties for the desired field?

Which tab Options, Actions, Validate?

I am guessing actions?

If Actions what is the "Select Trigger" I should choose?

What is the "Select Action" I should choose?

 

Here is the answer I was provided that would solve my issues.

"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."

try67
Community Expert
Community Expert
May 22, 2023

The custom Format script can be placed under the Format tab, Custom option, then Custom Format Script.

Click the "Edit..." button to enter the code:

 

 

The On Focus and On Blur events can be found under the Actions tab, with the action being "Run a JavaScript". Click the "Add..." button to enter the code: