Vue.prototype.checkNull = function(data, name) {
if (data == null) {
uni.showToast({
icon: "none",
title: name + "不能为空"
})
return true
}
return false
}
Vue.prototype.checkBlank = function(data, name) {
if (data == null || data == "") {
uni.showToast({
icon: "none",
title: name + "不能为空"
})
return true
}
return false
}
Vue.prototype.checkValidName = function(data, name) {
if (data == null || data == "") {
uni.showToast({
icon: "none",
title: name + "不能为空"
})
return true
} else if (!/^[\u4e00-\u9fa5]{2,15}$/.test(data)) {
uni.showToast({
icon: "none",
title: name + "内容不正确"
})
return true
}
return false
}
Vue.prototype.checkValidTel = function(data, name) {
if (data == null || data == "") {
uni.showToast({
icon: "none",
title: name + "不能为空"
})
return true
} else if (!/^1[0-9]{10}$/.test(data)) {
uni.showToast({
icon: "none",
title: name + "内容不正确"
})
return true
}
return false
}
Vue.prototype.checkValidEmail = function(data, name) {
if (data == null || data == "") {
uni.showToast({
icon: "none",
title: name + "不能为空"
})
return true
} else if (!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(data)) {
uni.showToast({
icon: "none",
title: name + "内容不正确"
})
return true
}
return false
}
Vue.prototype.checkValidStartAndEnd = function(start, end) {
let d1 = new Date("2000/01/01 " + start + ":00");
let d2 = new Date("2000/01/01 " + end + ":00");
if (d2.getTime() <= d1.getTime()) {
uni.showToast({
icon: "none",
title: "结束时间必须大于开始时间"
})
return true
}
return false
}
表单校验弹窗提醒
最新推荐文章于 2024-05-27 16:53:26 发布