Skip to main content
Known Participant
May 3, 2020
Question

Default text to clear upon entry in another text box

  • May 3, 2020
  • 2 replies
  • 733 views

I have two text boxes:  Name & Signature

Signature text box has default "XXXXXXX" unless overwritten, using this script:

    // On Focus script:

   if (event.target.value==event.target.defaultValue)

   {  event.target.value = "";  event.target.textColor = ["RGB", 0/255, 0/255, 128/255];

   }

   // On Blur script:

   if (event.target.value=="")

   {   event.target.value = event.target.defaultValue;   event.target.textColor = ["RGB", 0/255, 0/255,       128/255];

   }

 

I've used this script for other forms, however this form is different.  I do not expect user to input new information as it is intended for a wet signature, so I have made it "read only".  I would like to have the "X" text cleared if a user inputs into the Name field, and return if the Name field is blanked out.

How can I amended these scripts????

Thank you!

Michelle

This topic has been closed for replies.

2 replies

Thom Parker
Inspiring
May 3, 2020

Use a validation script on the name field to clear the signature field. 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
May 3, 2020

Hi Thom,

I'm sorry but I don't know how to phrase the script.  I'm still a newbie and the got the prior ones from help on this board.  Can you help me with it?

Thom Parker
Inspiring
May 4, 2020

Use almost exactly the same scripts, except, since its in the name field, instead of the signature field, the script needs to test for a non empty name field to clear the X's from the signature field. 

The script tests the current field value and sets the signature field value and properties.

 

"event.value" is the entered value of the name field. This replaces "event.target.value" in the previous script. 

 

Get the signature field using:

var oSigFld = this.getField("Signature");

 

You can read more about form scripting here:

https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm

 

 

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
May 3, 2020

I forgot to add.......the Name text boxes also have default "X" with the same script.  So maybe combine the two with Name box the lead..........default both Name and Signature to XXXX, but if Name box is overwritten, then Signature is cleared and if name is recleared (if user decides it is not needed), then both rever back to default "XXX"