checkPhone() {
      var mobile = '';
      var tel = /^0\d{2,3}-?\d{7,8}$/;
      var phone = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/; 
      if(mobile.length == 11){//手机号码
        if(phone.test(mobile)) {
          console.log(mobile);
          return true;
        }
      }else if(mobile.length == 12 && mobile.indexOf("-") != -1 ){//电话号码
        if(tel.test(mobile)) {
          console.log(mobile);
          return true;
        }
      }
        console.log('请输入有效的号码!'); 
    }

 

posted on 2018-04-17 15:20  阿梅M  阅读(23557)  评论(6编辑  收藏  举报