Mobile number limit

suresh101
Tera Contributor

I have created mobile number variable on record producer and type is single line text, as of now letters and numbers both are allowing to enter, so I tried with Variable attributes - max_length=10
it is restricting length 10 but it is allowing both numbers and letters, also I tried to create question_regex record and added below code, but still it is allowing both and more than 10 as well

 

suresh101_0-1742977521341.png

 

1 ACCEPTED SOLUTION

Hi @suresh101 ,

yeah update the regex to -> 

04\d{8}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@suresh101 

mobile format will vary based on country, some countries have 9 digit

So if you don't want to check for particular format then simply use this regex shared by @Chaitanya ILCR for allowing only numbers and max 10 numbers

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

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

Shivalika
Mega Sage

Hello @suresh101 

 

 

Use this - ^\d{10}$

 

As regex - it will accept only 10 digits from 0-9 and without space. 

 

Obviously, you can also go for OOB variable type - phone number. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY