Phone number format script

Abhishek Barik
Tera Contributor

Hi Team,

 

We have a requirement to make a variable in phone number format. Request you to please help in getting the script for it.

Thanks in advance,

Abhishek

1 ACCEPTED SOLUTION

Hi,

no client script required

You can create variable validation Regex and then attach it to the Variable

Validate U.S Phone Numbers using JavaScript Regular expression.

find_real_file.png

This will work for these phone number formats

E.g (308)-135-7895 or 308-135-7895 or 308135-7895 or 3081357895

^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$

find_real_file.png

find_real_file.png

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

there can be different formats like US phone number, India phone number

you can check with customer which exact format they require and based on that use Regex and use variable validation regex to achieve this

sharing links for help

Validation for number for variable in Catalog item

MOBILE NUMBER VALIDATION

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar 

It should be Us number validation only, Could you please provide the client script?

Hi,

no client script required

You can create variable validation Regex and then attach it to the Variable

Validate U.S Phone Numbers using JavaScript Regular expression.

find_real_file.png

This will work for these phone number formats

E.g (308)-135-7895 or 308-135-7895 or 308135-7895 or 3081357895

^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$

find_real_file.png

find_real_file.png

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader