Is valid phone number by regex - Node.js Regular expression

Node.js examples for Regular expression:Validation

Description

Is valid phone number by regex

Demo Code


var isValidPhoneNum = function(str){
    var reg = new RegExp(/^((13[0-9])|(147)|(15[^4,\D])|(17[0-9])|(18[0,0-9]))\d{8}$/);
    if(typeof str === 'string') return reg.test(str);
    return reg.test(str.toString());
};

Related Tutorials