What should be the Regular expression for validating multiple Indian mobile numbers which are separated by commas ,
like: .
+919883443344,+91-9883443344,919883443344,91-9883443344,09883443344,9883443344
That format should be acceptable.
You need to split the phones string and evaluate one by one. Try this function:
function validatePhonesString(phonesString){
var PHONE_NUMBER_REGEX = /(?:\+?91-?\d{10})|(?:0?\d{10})(\,(?:\+?91-?\d{10})|(?:0?\d{10}))*/;
var valid = true;
var phones = [];
phones = phonesString.split(',');
for (var i = 0; i < phones.length; i++) {
var phone = phones[i];
if (phone === '' || !PHONE_NUMBER_REGEX.test(phone)) {
valid = false;
}
}
return valid;
}
You can use the following regex:
(?:\+?91-?\d{10})|(?:0?\d{10})(\,(?:\+?91-?\d{10})|(?:0?\d{10}))*
tested on:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.