Mobile number formatting in +91 99 99 99 99 99

Kumar147
Tera Contributor

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.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Kumar147 

what did you try so far?

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

 

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(' ')  

 

Jaspal Singh
Mega Patron
Mega Patron

A simple regex as below should help

\+91\s\d\d\s\d\d\s\d\d\s\d\d\s\d\d