Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Regex Validation for Customfield

JayJuan Jones
Contributor
January 18, 2023

Can someone give me some ideas on how to validate my custom field "Phone Number"? This is a text field, and it accepts integer values, but we are running into issues where some of our external help desk members are not capturing all 10 digits of the phone number. 

Any way I can validate the field upon issue create using regex? Should the field be updated to a Number Field instead of a text field? Any suggestions? 

Also tried to use the regex in this KB article and that didn't work. 

^[0-9]{n}$

1 answer

0 votes
Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 18, 2023

Hi @JayJuan Jones

Are you trying validate for US number?

If so, can you try this?  This will accept phone numbers in the format of 123-456-7890 or (123) 456-7890.

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

Hope this helps.

Thanks,
Vamsi

JayJuan Jones
Contributor
January 18, 2023

hello @Vamsi Kandala I am trying to validate without the formatting so 1234567890

Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 18, 2023

Hi @JayJuan Jones

Can you try this?

^[0-9]{10}$

Thanks,
Vamsi

Like Els Bassant likes this

Suggest an answer

Log in or Sign up to answer