Copy link to clipboard
Copied
Useing Acrobat Pro 9, I have a few fields on a fillable form. On the text fields, the default text is "none". I'm trying to save my users some typing by clearing the text field when it is clicked on so they won't have to back space the word "none" out of the field before they enter something in it. But only the first time because I don't want what they entered into the filed to be cleared if they want to go back in and add to it. Here's what I tried in Field -> Properties -> Actions -> Mouse Down - Run a JavaScript ...
var X = "none"
var Y = this.getField("Speaker").value;
if (X == Y);
this.getField("Speaker").value = "";
else
this.getField("Speaker").value = Y;
This is supposed to check to see if the field contains the default value "none". If it does, it sets the field to "". If The field does not contain the default value "none" ii is supposed to leave what is in there. What happens is that it always clears the field no matter what is in it! I would appreciate some help on this. I'm an ASP programmer, never used JavaScript, much less in a PDF.
(No combination of curly brackets seems to be acceptable to the script checker.)
Thank you!
Jerry
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Try this:
if(event.target.value == "none"){
event.target.value = "";
}
Copy link to clipboard
Copied
Thank you very much! This worked perfectly.
Jerry
Copy link to clipboard
Copied
Drop the semi-colon after the if-statement... You can also drop the else-clause, as it does nothing, basically.
Copy link to clipboard
Copied
Thank you so much, this worked perfectly as well!
Jerry
Find more inspiration, events, and resources on the new Adobe Community
Explore Now