Default text to clear upon entry in another text box

Explorer ,
May 03, 2020

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

161

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Default text to clear upon entry in another text box

Explorer ,
May 03, 2020

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

162

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 03, 2020 0
Explorer ,
May 03, 2020

Copy link to clipboard

Copied

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"

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 03, 2020 0
Adobe Community Professional ,
May 03, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 03, 2020 0
Explorer ,
May 03, 2020

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 03, 2020 0
Adobe Community Professional ,
May 03, 2020

Copy link to clipboard

Copied

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

 

 

 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 03, 2020 0
Explorer ,
May 03, 2020

Copy link to clipboard

Copied

Again sorry Thom......I rethought how I explained it and found I may have left another part out or wasn't clear.  It really doesn't help when we don't give all the info!  ........this is where I'm at right now.........

 

NAME field default is "XXXXXXXX'.  This field has the original focus/blur action scripts I showed above.

SIGNATURE field is a read only field.  It also defaults to "XXXXXXXXX". (I removed the focus/blur actions)

 

GOAL:  If Name = XXXX (default value) then Signature = XXXX  (default value) else if Name = John Smith (typed in by user) then Signature is blank to allow John Smith to physically sign the document.  If the user were to type into the Name field which turns the Signature field null and then the user clears the Name field and it returns to the default, I want the Signature default to also return.

 

There are 5 rows of these name/signature fields that I want XXX'd out if not being used.  Once I figure out the first line I can replicate it to the rest.

The Name field currently works as expected.  I'm thinking I need to validate in the Signature field to work off the results of the Name field, but the multiple script versions I've tried aren't working exactly right.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 03, 2020 0
Explorer ,
May 04, 2020

Copy link to clipboard

Copied

After hours of playing with this, I finally got it to work.  Don't know if its the best way but its seems to work right now..............Both Name & Signature fields have XXX defaults; No action script in Signature.

In Name field, action script is:

// On Focus script:
var s = this.getField("Signature1");

if (event.target.value==event.target.defaultValue)
{ event.target.value = ""; s.value = "";
}

 

// On Blur script:
var s = this.getField("Signature1");

if (event.target.value=="")
{ event.target.value = event.target.defaultValue; s.value = s.defaultValue;
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 04, 2020 0