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

Field doesn't export as formatted

hammer09
Acrobat 9
Registered: May 19 2006
Posts: 15

Hi Thom,
 
I have a custom format script in a form field that I am using to change a number that is entered into a field. The problem I am having is that when the form is submitted or exported to an fdf file, it exports the value that was originally entered instead of what the field is being formatted to. How do I force the data to change to the format that I want. The format script that I am using is included below. You've helped me with another question about this script before. I am a beginner with javascript and would appreciate your help. Thanks!
 
The script I am using is shown below:
 
// RegExp input (999-999-9999) for format
var reHyphens = /^(\d{3})[-](\d{3})[-](\d{4})$/
var reNoHyphens = /^(\d{3})(\d{3})(\d{4})$/
var rePeriods = /^(\d{3})[.](\d{3})[.](\d{4})$/
var reSpaces = /^(\d{3})[ ](\d{3})[ ](\d{4})$/
if(reHyphens.test(event.value))
event.value = RegExp.$1 + "." + RegExp.$2 + "." + RegExp.$3;
else if(reNoHyphens.test(event.value))
event.value = RegExp.$1 + "." + RegExp.$2 + "." + RegExp.$3;
else if(rePeriods.test(event.value))
event.value = RegExp.$1 + "." + RegExp.$2 + "." + RegExp.$3;
else if(reSpaces.test(event.value))
event.value = RegExp.$1 + "." + RegExp.$2 + "." + RegExp.$3;

Chad Chelius
Chelius Graphic Services
chad [at] cheliusgraphicservices [dot] com

My Product Information:
Acrobat Pro 7, Macintosh
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The formatted value is what is visually presented to the user by Acrobat. It's not the value of the field.

To make the formated value the export value you have to move this script to the Commited Keystroke event like this.



if(event.willCommit)
{
.... All your existing code ...
}

Thom Parker
WindJack Solutions
[url=http://www.windjack.com]www.windjack.com[/url]

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

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

hammer09
Acrobat 9
Registered: May 19 2006
Posts: 15
Thanks Thom! I tried this and at first it seemed to break the script, however I then realized that I needed the ! in front of the event.commit. That being said, now it formats as it had been but it still doesn't export the actual value that the script formats it to, it exports as the originally entered text. At this point I can't figure out why it isn't exporting the content as it is formatted. I've included my current script below. I'd really appreciate your input on this. Thanks!

if(!event.willCommit)
{
// RegExp input (999-999-9999) for format
var reHyphens = /^(\d{3})[-](\d{3})[-](\d{4})$/
var reNoHyphens = /^(\d{3})(\d{3})(\d{4})$/
var rePeriods = /^(\d{3})[.](\d{3})[.](\d{4})$/
var reSpaces = /^(\d{3})[ ](\d{3})[ ](\d{4})$/
if(reHyphens.test(event.value))
event.value = RegExp.$1 + "." + RegExp.$2 + "." + RegExp.$3;
else if(reNoHyphens.test(event.value))
event.value = RegExp.$1 + "." + RegExp.$2 + "." + RegExp.$3;
else if(rePeriods.test(event.value))
event.value = RegExp.$1 + "." + RegExp.$2 + "." + RegExp.$3;
else if(reSpaces.test(event.value))
event.value = RegExp.$1 + "." + RegExp.$2 + "." + RegExp.$3;
}

Chad Chelius
Chelius Graphic Services
chad [at] cheliusgraphicservices [dot] com