vue 验证iview表单
邮箱验证
dzyx: [
{required: true, message: i18n('VALIDATE.NOT_NULL')}
,{ validator (rule, value, callback) {
const reg = /^(([^<>()\[\]\\.,;:\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,}))$/
var flag = reg.test(value)
if (flag) {
callback()
} else {
callback(new Error('请输入正确的邮箱地址'))
}
}}
]
验证时间datetimerange
ksqssj: [{ required: true, type: 'array', message: i18n('VALIDATE.NOT_NULL'), trigger: 'change' },
{ validator (rule, value, callback, source, options) {
const errors = []
if (value[0] === '') { errors.push(i18n('VALIDATE.NOT_NULL')) }
callback(errors)
} }],