Copy link to clipboard
Copied
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!
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
Copy link to clipboard
Copied
When you use rich text format in the text field you can assign a web link to the text.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank you all for giving these helpful hints. I tried the script and it works.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now