Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Phone Number Format does not transfer to text fields

Duquette
Level 1
Level 1

I am working on a form where the user enters their information in fields to generate a report. How can I  keep the formatting for the phone numbers entered into the field to transfer to the text field. when the report is generated? I need (123) 456-7890 but end up with 1234567890

acrobat DC javascript
1 Accepted Solution
Manjunath_K
Correct answer by
Community Advisor
Community Advisor

@Duquette,

Have you tried adding custom logic in javascript to format this phone number? if not please try adding below logic to format phone number with 10 digits.

 

var phoneNumber = '1234567890';

if(phoneNumber.length == 10){
phoneNumber = '('+phoneNumber.substr(0,3)+') '+phoneNumber.substr(3,3)+'-'+phoneNumber.substr(6); //returns formatted phone number (123) 456-7890
}

 

Hope this helps! 

View solution in original post

4 Replies
Duquette
Level 1
Level 1

I am assigning the value to a variable then recalling it in the report..

 

// Primary Contact Information;

if (pcn.value === ""){
event.value = "Primary Contact:\n\n\nNo Primary Contact on File";
}
else{

event.value = "Primary Contact:\n\n"+pcn.value+"\nWork: "+pcp.value+"\nCell: "+pcpc.value+"\nEmail: "+pce.value;
}

Manjunath_K
Correct answer by
Community Advisor
Community Advisor

@Duquette,

Have you tried adding custom logic in javascript to format this phone number? if not please try adding below logic to format phone number with 10 digits.

 

var phoneNumber = '1234567890';

if(phoneNumber.length == 10){
phoneNumber = '('+phoneNumber.substr(0,3)+') '+phoneNumber.substr(3,3)+'-'+phoneNumber.substr(6); //returns formatted phone number (123) 456-7890
}

 

Hope this helps! 

View solution in original post

Duquette
Level 1
Level 1
Manjunath, Thank you for your help - I had tried several variations to format the phone number - the solution was a combination of your help and declaring the variable as a string. Again - Thank You!