/*邮箱验证*/
export function validateEmail(email) {
const re = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
return re.test(email)
}
/*传真验证*/
export function validateFax(fax) {
const re = /^(\d{3,4}-)?\d{7,8}$/
return re.test(fax)
}
/*url验证*/
export function validateUrl(url) {
const re =/^([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$/
return re.test(url)
}
/*手机号验证*/
export function validatePhone(phone) {
const re=/^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-2,5-9])|(17[0-2,5-9]))\d{8}$/g
return re.test(phone)
}
/*座机号验证*/
export function checkPhone(phone) {
const re=/^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/
return re.test(phone)
}
//IP地址验证
export function IP(ip) {
const re=/^((25[0-5]|2[0-4]\d|[01]?\d\d?)($|(?!\.$)\.)){4}$/
return re.test(ip)
}
// 6-18位字母和数字组合
export function accountName(accountName) {
const re=/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,18}$/
return re.test(accountName)
}
// 电话号码中间四位加密
phone = phone .replace(/(\d{3})(\d{4})(\d{4})/, '$1****$3')
// 车牌验证,包含新能源
var reg = /^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](https://segmentfault.com/a/1190000012427912#)|([DF](https://segmentfault.com/a/1190000012427912#)[0-9]{4})))|(京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/
持续更新中...