Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
14

Custom formatting disappears ???

Participant ,
Mar 29, 2024 Mar 29, 2024

I have a telephone number field in a "fill-in" PDF file.

I'm using a Custom Format Script to create a multi-line Tool Tip.

this.getField("Preferred_Phone_Number").userName = "Enter Preferred Phone Number (10-Digits)\n(Ingrese el número de teléfono preferido)"; 

Then, in the same field, I go to the Format Tab and choose Select format category and choose Special, Phone Number.  Everything appears to be working, the multi-line tool tip and the phone number format. (123) 456-7890.

Now, if I need to modify the multi-line Tool Tip, the Java Script under Custom Format Script is gone?  I have to recreate the entire Java Script?  WHY?  Then I have to reselect the Special Phone Number format.  Am I doing something wrong?

Can't Adobe Acrobat remember 2 different formats?

BTW, running Adobe Acrobat Standard 2020.

 

TOPICS
Edit and convert PDFs , JavaScript , PDF , PDF forms
868
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Mar 31, 2024 Mar 31, 2024
LATEST

You'll need an automation tool to do this. You can download one here.  

https://www.pdfscripting.com/public/Free_Acrobat_Automation_Tools.cfm

It works on standard the same as Reader. 

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 29, 2024 Mar 29, 2024

What script do you use under Custom Format Script?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 29, 2024 Mar 29, 2024

It was in my original post.  But here it is again.

this.getField("Preferred_Phone_Number").userName = "Enter Preferred Phone Number (10-Digits)\n(Ingrese el número de teléfono preferido)"; 
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 29, 2024 Mar 29, 2024

EDIT: I misread your post. Why not set tool tip manually?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 29, 2024 Mar 29, 2024

Hi again Nesa,

You have the script that provides the multi line tool tip. 

Can you provide me with the script that I need to add to also format the telephone number as: (###) ###-####?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 29, 2024 Mar 29, 2024

Try this:

event.target.userName = "Enter Preferred Phone Number (10-Digits)\n(Ingrese el número de teléfono preferido)";
if(event.value)
 event.value = util.printx("(999) 999-9999", event.value);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 29, 2024 Mar 29, 2024

Well? It works, except.

Now there's no validation.  They have to enter 10 digits for a telephone number. 

I can limit them to a maximum of 10 digits, but I can't prevent them from entering fewer than 10 digits.

For example: 2125551212 returns (212) 555-1212, but 212555121 returns (212) 555-121.  No error checking.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 29, 2024 Mar 29, 2024

Yes, you are doing something wrong, actually more than one thing.  There can be only one format script, you cannot have both the custom script and the special formatting. Both are in fact scripts that occupy the same space. 

The tooltip script is not related to formatting so it can be placed somewhere else. For example the custom Validation Script would be perfect for this. 

 

However, the tooltip script is unnecessary. The tooltip only needs to be set once, not every single time the field is updated. So, run your tooltip script from the console window to set the tooltip once. Then save the file, and your done. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 31, 2024 Mar 31, 2024

Can you direct me as to how I get to the console window?

I'm running Adobe Acrobat Standard 2020.

I've watched educational videos on YouTube, and when he clicked on the Main Tools Tab, and scrolled to the very bottom, the video shows a JavaScript Tool where he clicked on open.

But, I don't have that JavaScript Tool Icon.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 31, 2024 Mar 31, 2024
LATEST

You'll need an automation tool to do this. You can download one here.  

https://www.pdfscripting.com/public/Free_Acrobat_Automation_Tools.cfm

It works on standard the same as Reader. 

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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