Mobile number formatting in +91 99 99 99 99 99
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 04:55 AM
Hello all,
I have a requirement to set the mobile number entered in field in the format of +91 99 99 99 99 99. I tried many validations and not worked, can anyone help me on this to set this kind of format.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 04:59 AM
what did you try so far?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 05:02 AM - edited 08-10-2023 05:03 AM
Hello Ankur
var rex = reg.replace(/\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*(\d{2})/, '$1 $2 $3 $4 $5 $6 &7');
(/(\d{1})(\d{3})(\d{3})(\d{4})/, `+$1 $2 $3 $4`);
[string.slice(0, 3), string.slice(3,7), string.slice(7)].join(' ')

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 05:00 AM
A simple regex as below should help
\+91\s\d\d\s\d\d\s\d\d\s\d\d\s\d\d