Hi Thom,
I look forward to seeing you at this year's PDF conference! Question: I have a javascript that I muddled through (with others' help) to force the formatting of a phone number. Currently, I have a custom format script for the field that looks like this:
// RegExp input (999-999-9999) for format
var re = /^(\d{3})[-](\d{3})[-](\d{4})$/
if(re.test(event.value) == true)
{
event.value = RegExp.$1 + "." + RegExp.$2 + "." + RegExp.$3;
}
and a custom keystroke script that looks like this:
// RegExp input (999-999-9999) for format
var re = /^(\d{3})[-](\d{3})[-](\d{4})$/
if(re.test(event.value) == true)
{
event.value = RegExp.$1 + "." + RegExp.$2 + "." + RegExp.$3;
}
It is currently taking input of a number in the format of 555-555-5555 and converts it to 555.555.5555. I need to add the functionality to the script so that it will take input of 5555555555 and format it in the same way. I'm not sure where to go about modifying my script to make this happen. Can you help? Thanks!
1. Modify the RegEx to make the dashes optional.
/^(\d{3})[-]?(\d{3})[-]?(\d{4})$/
2. Use the util.printx() function instead of a regular expression. This function will take the first 10 digits no matter what is separating them.
Your keystroke script doesn't do anything. Get rid of it.
Thom Parker
WindJack Solutions
[url=http://www.windjack.com]www.windjack.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://partners.adobe.com/public/developer/en/acrobat/sdk/
pdf/javascript/AcroJS.pdf]Acrobat JavaScript Reference[/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script