These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

PDF Javascript - Script to replace special characters

tfarzalo
Registered: Apr 14 2009
Posts: 2
Answered

I need a javascript that I can place in a form field properties area that will replace a "&" symbol with the word "and".....any help would be greatly appreciated.

My Product Information:
Acrobat Pro 9.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are a couple of places you can enter a script that modifies the contents of the field. The question is, do you want the value of the form field to be altered, or just what the user sees on the screen?

To modify the value of the field you will need to use a custom keystroke script. To modify the appearance of the field you will need to enter a format script. You can find articles on both of these in the tutorial on this site.

The script itself can be done with the JavaScript "replace" function, In both cases (assuming that you've got an AcroForm) the code will look like this

event.value = event.value.replace(/\&/g,"and");Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script