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

customer format script for url link

New Here ,
Jun 10, 2017 Jun 10, 2017

Hi, does anyone know if its possible to write a script to put in the Format > Custom > Customer Format Script section of a Text Field so that only hyperlinks (URL) can be entered?  So, after the link is entered, I can just click on it and bring me to the web page?

Thanks!

TOPICS
Acrobat SDK and JavaScript
740
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

correct answers 1 Correct answer

Community Expert , Jun 11, 2017 Jun 11, 2017

That's not what Format scripts are used for. What you're describing is a Validation script, but validating a URL is extremely complicated.

I would advice against it.

Your second request is possible too, but also tricky.

If each time the user clicks the field it will launch the URL in it, it will be very difficult to edit it...

What I would do is set the field to launch the URL only when the Ctrl (or Cmd on a Mac) key is held down.

You can use this code as the field's MouseUp action to do it:

if (event

...
Translate
Community Expert ,
Jun 11, 2017 Jun 11, 2017

When you use rich text format in the text field you can assign a web link to the text.

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 ,
Jun 11, 2017 Jun 11, 2017

That's not what Format scripts are used for. What you're describing is a Validation script, but validating a URL is extremely complicated.

I would advice against it.

Your second request is possible too, but also tricky.

If each time the user clicks the field it will launch the URL in it, it will be very difficult to edit it...

What I would do is set the field to launch the URL only when the Ctrl (or Cmd on a Mac) key is held down.

You can use this code as the field's MouseUp action to do it:

if (event.target.value && event.modifier) app.launchURL(event.target.value);

Maybe add a tooltip that lets the user know they can Ctrl+Click the field to launch the URL directly.

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 ,
Jun 11, 2017 Jun 11, 2017

About your first request, you should search for "How To Add Validations To A PDF Form" on this page: PDF Form Validation|Advanced Acroform Toolset|PDF Calendar|PDF File Upload|Required Dropdown

This free utility is a must have.


Acrobate du PDF, InDesigner et Photoshopographe
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
New Here ,
Jun 11, 2017 Jun 11, 2017
LATEST

Thank you all for giving these helpful hints.  I tried the script and it works.

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