正则匹配手机号

版权声明:内容多为自言自语,请自行判断有无价值。 https://blog.csdn.net/weixin_41702247/article/details/83040202
function check(num){
    if((/^1[3578]\d{9}$/).test(num)){    //以1开头,第二个数字是3578中的一个,后九位都必须是数字,结束
        console.log('Right number!');
    }else{
        console.log('Phone number is wrong!');
    }
}
check(13566666666);    //Right number!
check('hello');        //Phone number is wrong!

猜你喜欢

转载自blog.csdn.net/weixin_41702247/article/details/83040202