haw-utils
Version:
一个基于业务场景的工具方法库
45 lines (43 loc) • 1.14 kB
JavaScript
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports"], factory);
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var mod = {
exports: {}
};
factory(mod.exports);
global.isMobile = mod.exports;
}
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports["default"] = void 0;
// 手机号码 11位数字,以1开头,第二位是3456789其中一个,后面再加9个数字
var reg = /^1[3456789]\d{9}$/;
/**
* 检测值是否为手机号码
*
* @static
* @alias module:Validator.isMobile
* @since 1.1.0
* @param {String} value 要检测的值
* @returns {Boolean} 值是否为手机号码
* @example
*
* isMobile('13000000000');
* // => true
*
* isMobile('13000');
* // => false
*
*/
function isMobile(value) {
return reg.test(value);
}
var _default = isMobile;
_exports["default"] = _default;
});