vue3自定义确认密码匹配验证规则

vue3自定义确认密码匹配验证规则_第1张图片

// 自定义确认密码匹配验证规则
const matchPassword = (rules:any, value:any, callback:any) => {
	if (value != addData.payPwd) {
		callback(new Error('两次密码输入不一致!'))
	} else {
		callback()
	}
}


const rules = reactive({
  payPwd: [
    { required: true, message: "请输入支付密码", trigger: "blur" },
    {
      pattern: /^\d+$/,
      message: "只能输入6位数字",
      trigger: "blur",
    },
  ],
  repeatedPwd: [
    { required: true, message: "请输入支付密码", trigger: "blur" },
    {
      pattern: /^\d+$/,
      message: "只能输入6位数字",
      trigger: "blur",
    },
    {validator: matchPassword, trigger: 'blur'}
  ],
});

 
      
        
          
        
        
          
        
      

      
    

你可能感兴趣的:(vue.js,elementui,javascript)