📜  validador de telefone javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:04.330000             🧑  作者: Mango

代码示例1
function validPhone (phone) {
    var regex = new RegExp('^\\([0-9]{2}\\)((3[0-9]{3}-[0-9]{4})|(9[0-9]{3}-[0-9]{5}))$');
    return regex.test(phone);
}

validPhone('(31)3534-2323'); //Valido
validPhone('(31)9923-23288'); //Valido
validPhone('(31)9923-3288'); //Invalido
validPhone('(31)2323-5443'); //Invalido