
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2021 11:20 AM
We have a requirement to have a standard format for the phone number field to be XXX-XXX-XXXX (with hyphens). Do you have any suggestions how i can achieve this by validation regex?
Thank you in advance
Solved! Go to Solution.
Labels:
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2021 11:26 AM
Hi Diane,
We use this Regular Expression in a Variable Validation Regex for US Phone Numbers.
^\(?([0-9]{3})\)?[-]([0-9]{3})[-]([0-9]{4})$
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2025 12:25 AM
Try Below Code to convert Phone Number in xxx-xxx-xxxx
var pattern = /[^a-zA-Z0-9]/g;
var cleanPhoneNum = phoneNum.replace(pattern, "");
var formatPhn = cleanPhoneNum.substring(0,3)+"-"+cleanPhoneNum.substring(3,6)+"-"+cleanPhoneNum.substring(6,11);
Please mark correct if you find the above solution helpful. 🙂