一些判断函数 发表于 2019-07-04 | 更新于: 2019-11-05 | 分类于 JavaScript工具函数 | 浏览 字数统计: 155 | 阅读时长 ≈ 1 各种判断函数 1234567891011121314151617181920212223// 合法数字let isNumber = (num) => /^[0-9]+.?[0-9]*/g.test(num)// 手机号let isPhone = (num) => /^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/.test(num)// 邮箱let isEmail = (email) => /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(email)// 身份证号let isCardNo = (card) => /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(card)// 微信浏览器let isWeChat = () => /MicroMessenger/i.test(navigator.userAgent)// 微信开发者工具let isWeChatDevTool = () => isWeChat() && /wechatdevtools/i.test(navigator.userAgent)//支付宝浏览器let isAliPay = () => /AlipayClient/i.test(navigator.userAgent)// 移动端let isMobile = () => /(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)