/**
- 邮箱
- @param {*} s
*/
export function isEmail (s) {
return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(s)
}
/**
- 手机号码
- @param {*} s
*/
export function isMobile (s) {
return /^1[0-9]{10}$/.test(s)
}
/**
- 电话号码
- @param {*} s
*/
export function isPhone (s) {
return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(s)
}
/**
- URL地址
- @param {*} s
/
export function isURL (s) {
return /^http[s]?😕/./.test(s)
}
/* 小写字母 */
export function isLowerCase (str) {
const reg = /1+$/
return reg.test(str)
}
/* 大写字母 */
export function isUpperCase (str) {
const reg = /2+$/
return reg.test(str)
}
/* 大小写字母 */
export function isAlphabets (str) {
const reg = /3+$/
return reg.test(str)
}
/* 验证pad还是pc */
export const isPc = function () {
const userAgentInfo = navigator.userAgent
const Agents = [‘Android’, ‘iPhone’,
‘SymbianOS’, ‘Windows Phone’,
‘iPad’, ‘iPod’]
let flag = true
for (let v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false
break
}
}
return flag
}
/**
- 判断姓名是否正确
*/
export function isName (name) {
let regName = /4{2,4}$/
if (!regName.test(name)) return false
return true
}
/**
- 判断是否为整数
*/
export function isNum (num, type) {
let regName = /[^\d.]/g
if (type === 1) {
if (!regName.test(num)) return false
} else if (type === 2) {
regName = /[^\d]/g
if (!regName.test(num)) return false
}
return true
}
/**
- 判断是否为小数
*/
export function isFloat (num) {
let regName1 = /^\d+(.\d+)?KaTeX parse error: Can't use function '\.' in math mode at position 30: … = /^(-(([0-9]+\̲.̲[0-9]*[1-9][0-9…/
if (regName1.test(num) || regName2.test(num)) return true
return false<