I've looked all afternoon to try and find this one. Basically, I want get the name of the current text field and change the display value to noPrint if the text field value is "--". I'm running this as a validation script in a PDF. Any help is much appreciated!
if(event.value == '--')
{
event.target.name.display = event.target.name.display.noPrint;
} else
{
event.target.name.display = event.target.name.display.visible;
}
You have a couple of things a bit off.
event.value
doesn't exist (you can check the available event properties)
If you want to get the value of the element that triggered the event you can do:
var elemValue = event.target.value;
If you want to get the name for the same element you can do:
var elemName = event.target.name;
To hide the element from printing, you can see this answer.