Format for Cell Phone Number in Spans Coding
Hi, I’m working with a pdf form, the first page is an input page with fields for various info like Employee Name, Title, Telephone Number, and Cell Phone Number. The second page is a business card with the information entered from the first page.
On the second page, I have a text field named Employee Block which combines the employee name, title, telephone number, FAX number, cell phone number and email address.
The telephone and FAX number fields are drop-downs with numbers to choose from, (in this format: (xxx) xxx-xxxx), the cell phone number field is completed by the user. The Format properties of the CellPhone field is set to Special under the Select formatting category and Phone Number is chosen for Special Options so when the user types in the number in the CellPhone field it is formatted as (xxx) xxx-xxxx.
However, the cell phone number shows as 10 numbers all together, no () and no – in the Employee Block field.
I need assistance in the coding that would be used in spans[3] area for the cell phone number to appear as (xxx) xxx-xxxx.
The Employee Block field has the following custom calculation script:
var spans = event.richValue;
spans[0] = new Object();
spans[0].text = this.getField("EmpName").valueAsString + "\r";
spans[0].textColor = ["RGB", 0.70, 0.059, 0.255];
spans[0].fontWeight = 700;
spans[0].textSize = 10;
spans[1] = new Object();
spans[1].text = this.getField("MeritTitle").valueAsString + "\r \r";
spans[1].textColor = ["RGB", 0, 0.219, 0.133];
spans[1].fontWeight = 700;
spans[1].fontStyle ="italic";
spans[1].textSize = 8;
spans[2] = new Object(); //if there is no Extension, then Ext. will be hidden
spans[2].text = this.getField("Telephone").valueAsString + ", FAX: " + this.getField("FAX").valueAsString + "\r";
if(this.getField("FAX").valueAsString =="")spans[2].text= this.getField("Telephone").valueAsString + "\r";
spans[2].textColor = ["RGB", 0, 0.219, 0.133];
spans[3] = new Object(); //cell phone number
spans[3].text = this.getField("CellPhone").valueAsString + "\r";
if(this.getField("CellPhone").valueAsString =="")spans[3].text=8;
spans[3].textColor = ["RGB", 0, 0.219, 0.133];
spans[4] = new Object(); //if no e-mail is entered then @countyofmerced.com will be hidden.
spans[4].text = this.getField("EmailAdd").valueAsString;
if(spans[4].text != "")spans[4].text += "@countyofmerced.com";
spans[4].textColor = ["RGB", 0, 0.219, 0.133];
spans[4].textSize=8;
event.richValue = spans;
Thank you, Jamie
