I am wrting a regex to validate telephone numbers for e164 format . My requirement is after country code there should be space mandatory after then the number like
+91 1111111111 — > validate true
+911111111111 — > validate false.
Like this validate for all countries in general . I have written the below regex
function validatePhoneForE164(phoneNumber) {
const regEx = /^+?[1-9]sd{1,14}$/;
return regEx.test(phoneNumber);
};
console.log(validatePhoneForE164(‘+91 1111111111’))
this is working for US +1 1111111111 , but not working for others
function validatePhoneForE164(phoneNumber) {
const regEx = /^+?[1-9]sd{1,14}$/;
return regEx.test(phoneNumber);
};
console.log(validatePhoneForE164(‘+91 1111111111’))
this is working for US +1 1111111111 , but not working for others