源文件
This commit is contained in:
37
jeepay-ui-uapp-agent/hooks/validate.js
Normal file
37
jeepay-ui-uapp-agent/hooks/validate.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// 校验手机号
|
||||
function REG_Phone(arg) {
|
||||
const reg = /^1\d{10}$/
|
||||
return reg.test(arg)
|
||||
}
|
||||
// 校验邮箱
|
||||
function REG_Email(arg) {
|
||||
const reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/
|
||||
return reg.test(arg)
|
||||
}
|
||||
// 校验登录名
|
||||
function REG_LoginName(arg) {
|
||||
const reg = /^[a-zA-Z][a-zA-Z0-9]{5,19}$/
|
||||
return !!arg && reg.test(arg)
|
||||
}
|
||||
// 非空校验
|
||||
function REG_NotNUll(arg) {
|
||||
return !!arg
|
||||
}
|
||||
// 校验货币金额 真能是正数包含小数点
|
||||
function takeMoney(arg) {
|
||||
const reg = /(?:^[1-9]([0-9]+)?(?:\.[0-9]{1,2})?$)|(?:^(?:0)$)|(?:^[0-9]\.[0-9](?:[0-9])?$)/
|
||||
return reg.test(arg)
|
||||
}
|
||||
// 检验网址链接
|
||||
function httpOrHttps(arg) {
|
||||
const reg = /^(http|https)/
|
||||
return reg.test(arg)
|
||||
}
|
||||
export default {
|
||||
REG_Phone,
|
||||
REG_Email,
|
||||
REG_LoginName,
|
||||
REG_NotNUll,
|
||||
takeMoney,
|
||||
httpOrHttps,
|
||||
}
|
||||
Reference in New Issue
Block a user