
- 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.
- 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})$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2021 11:24 AM
Try this
^([0-9]{3}-){2}[0-9]{4}$")
Sharing one more combination
/^(?:\(\d{3}\)|\d{3}-)\d{3}-\d{4}$/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2021 11:30 AM
- 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})$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2021 11:48 AM
Hi
One ServiceNow Community member has a useful thread from a couple of years ago.
Please go through this answer of Brad here:-
How to validate a string field for proper phone number format
I hope this will help you.
Mark ✅ Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks & Regards,
Tejas Tamboli