let Validate = function (type) {
this.numberExg = /[^\d]/g; //数字
this.numberDecimalExg = '/[^\d\.]+?/g'; //数据,小数点
this.phoneNumArr = [134, 135, 136, 137, 138, 139, 150, 151, 152, 158, 159, 178, 157, 181, 182, 187, 188, 147, 149, 145, 130, 131, 132, 155, 156, 185, 186, 183, 184, 133, 153, 180, 189, 177, 173, 175, 176, 170, 171];
}
Validate.prototype = {
constructor: Validate,
/*
* 校验手机号
*/
ifPhoneNum: function (val) {
//增加了校验的严谨性
let tel = String(val).replace(/-/g,'').replace(/\s/g,'');
if(isNaN(Number(tel))){
return false;
}
if(tel.length!=11){
return false;
}
return this.phoneNumArr.indexOf(parseInt(tel.substr(0, 3))) > -1;
}
}
export default Validate;