js验证隐藏中间四位的手机号

验证是否是手机号:

function checkPhone(phone) {
    var phoneLength = phone.length;
    var top_four = phone.substring(0,3);
    var lst_four = phone.substring(phoneLength-4,phoneLength);
    var top_four_bool = /^[0-9]+$/.test(top_four);
    var lst_four_bool = /^[0-9]+$/.test(lst_four);
    if(!top_four_bool || !lst_four_bool){
        return false;
    }else{
        return true;
    }
}

 

你可能感兴趣的:(Jquery,Javascript,js)