Python
前端
vue
// elementplus的规则校验
amount: [
{required: true, message: '金额不能为空', trigger: 'blur'},
{pattern: /^[0-9]+$/, message: '输入金额必须为数字(正整数), trigger: 'blur'},
]
// 确认密码校验
const validatePassword = (rule, value, callback) => {
if (value === '') {
callback(new Error('确认密码不能为空'))
} else if (value !== currentState.form.password) {
callback(new Error("密码不一致"))
} else {
callback()
}
}
const currentState = reactive({
rules: {
"name": [
{required: true, message: '企业名称不能为空', trigger: 'blur'},
],
"mobile": [
// {required: true, message: '手机号不能为空', trigger: 'blur'},
// {pattern: /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/, message: '手机号格式不正确', trigger: 'blur'}
],
"code": [{required: true, message: '验证码不能为空', trigger: 'blur'},],
"password": [{required: true, message: '密码不能为空', trigger: 'blur'},],
"confirm_password": [
{required: true, message: '确认密码不能为空', trigger: 'blur'},
{validator: validatePassword, trigger: 'blur'},
],
}
})