Skip to main content
Participant
June 11, 2017
Answered

customer format script for url link

  • June 11, 2017
  • 3 replies
  • 835 views

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!

This topic has been closed for replies.
Correct answer try67

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.

3 replies

Participant
June 11, 2017

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

JR Boulay
Community Expert
Community Expert
June 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
Bernd Alheit
Community Expert
Community Expert
June 11, 2017

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

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 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.