export function interValidate(str) {
const reg = /^[0-9]*[1-9][0-9]*$/
return reg.test(str)
}
export function phoneValidate(phone) {
const reg = /^[1][3,4,5,7,8,2,6,9,1,0][0-9]{9}$/
return reg.test(phone)
}
export function floatValidate(str) {
const reg = /^([1-9][\d]{0,7}|0)(\.[\d]{1,2})?$/
return reg.test(str)
}
export function validateURL(textval) {
const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
return urlregex.test(textval)
}
export function validateLowerCase(str) {
const reg = /^[a-z]+$/
return reg.test(str)
}
export function validateUpperCase(str) {
const reg = /^[A-Z]+$/
return reg.test(str)
}
export function validateAlphabets(str) {
const reg = /^[A-Za-z]+$/
return reg.test(str)
}
export function emailValidate(email) {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
return re.test(email)
}
export function validateInterAndZero(num) {
const reg = /^([1-9]\d*|[0]{1,1})$/
return reg.test(num)
}
export function isCardNo(value) {
const reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
return reg.test(value)
}
export function passwordValidate(str) {
const reg = /^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&*]+$)(?![\d!@#$%^&*]+$)[a-zA-Z\d!@#$%^&*]+$/
return reg.test(str)
}
export function logonValidate(str) {
const reg = /(^\d{15}$)|(^\d{18}$)/
return reg.test(str)
}
- 营业执照号
'/^\d{15}$/'
'/^(?:(?![IOZSV])[\dA-Z]){2}\d{6}(?:(?![IOZSV])[\dA-Z]){10}$/'
'/(^(?:(?![IOZSV])[\dA-Z]){2}\d{6}(?:(?![IOZSV])[\dA-Z]){10}$)|(^\d{15}$)/'
- 统一社会信用代码
/[^_IOZSVa-z\W]{2}\d{6}[^_IOZSVa-z\W]{10}$/g
- 手机号中间四位*号显示
String(phone).replace(/^(\d{3})\d{4}(\d{4})$/, '$1****$2')
- 密码强度校验
**
export function passwordStrengthValidate(str) {
const reg = /(?!^(\d+|[a-zA-Z]+|[~!@#$%^&*?]+)$)^[\w~!@#$%^&*?]{8,16}$/
return reg.test(str)
}**
- 银行卡校验
const reg = /^([1-9]{1})(\d{14}|\d{18})$/