phone number verification

Regular

function checkMobile(str) {
    var reg = /^(0|86|17951)?(13[0-9]|15[012356789]|17[0135678]|18[0-9]|14[57])[0-9]{8}$/;
    if(str.match(reg)){
        return true;
    } else{
        return false;
    }
}

Check data integrity

//弹窗提交的校验
function inspect(){
    //提交的操作
    $('.btn').click(function(){
        if(checkDatas($(this).parent().find('ul:visible').find(".contentmobilea"))){   //拿到电话号码的input
            Popups.close('.applytrial1');
            Popups.close('.Feedback');
        }else{
            
        }
    });
    
    // 检查数据完整性
    function checkDatas(type) {
        // 检查手机号
        var contactTel =type.val();//取input的value
        console.log(contactTel)
        var flag = true;
        if (contactTel == '' || contactTel == null || contactTel == undefined) {
            $('.contentmobile').html('手机号不能为空');
            flag = false;
            return flag;
        }
        if (!checkMobile(contactTel)) {
            $('.contentmobile').html('请输入正确的手机格式');
            flag = false;
            return flag;
        }
        return flag;
    }
}

Instructions

html code of the page

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325565166&siteId=291194637