Copy link to clipboard
Copied
Hello everyone,
Maybe someone has a solution for my problem. In a form I have several fields that are defined by the following javascript
The default value is: "Click or tap here to enter text."
the first code action:
Activate field:
if(event.target.value==event.target.defaultValue) event.target.value="";
the second code action:
Deactivate field:
if(event.target.value=="")event.target.value=event.target.defaultValue ;
This means that the placeholder in the field says “Click or tap here to enter text.”. If you click on the field something else can be written. If nothing is changed, the placeholder appears again.
Now I woudl like to have this:
If the field is not filled with new text, i.e. if the default value is not changed, the field should not be printed. It should only be printed when the value changes.
I tried with this expression:
var oFld = this.getField(FieldName);
oFld.display = (oFld.value == oFld.defaultValue)?display.noPrint:display.visible;
but it doesn't work. The field is still printing
Maybe someone has a solution?
Thank you very much
Copy link to clipboard
Copied
Where is this code? In what event script?
It is a bad idea to set the default to help text.
A better solution is to use a custom format script to display the help text.
Format Script:
if(event.value == "")
{
event.value = "Click or tap here to enter text.";
event.target.display = display.noPrint;
}
else
event.target.display = display.visible;
Now you don't have to do bizare things to fixup the field value.
Copy link to clipboard
Copied
Where is this code? In what event script?
It is a bad idea to set the default to help text.
A better solution is to use a custom format script to display the help text.
Format Script:
if(event.value == "")
{
event.value = "Click or tap here to enter text.";
event.target.display = display.noPrint;
}
else
event.target.display = display.visible;
Now you don't have to do bizare things to fixup the field value.
Copy link to clipboard
Copied
Hello Thom,
Thank you very much for your answer and your suggested solution. It seems to work exactly as I imagined. Your solution is much better and more practical.
So that you can understand where I had my scripts, I created and uploaded screenshots for you. The advantage of this variant is that the standard value automatically disappears when you click in the field. In your version you have to select the text and then delete it - but that's not so dramatic.
Thank you for your solution.
Copy link to clipboard
Copied
Hello Thom,
maybe you also have the solution for a drop down menu. If "Select an item" (default value) is selected, the field should not be printed. I changed "Click or tap here to enter text" in "Select an item" in your code. But unfortunately it doesn't work.
I have also attached a screenshot.
Thank you
Copy link to clipboard
Copied
For a dropdown you can use a validation script to set the visibility.
It always a good idea to also set the "Commit selection immediately" option.
Here's a custom validation script.
event.target.display = (event.value == event.target.defaultValue)?display.noPrint:display.visible;