javascript - 使用 vuelidate 和 vue 3 验证确认密码字段的问题
问题描述
我在 vuelidate for vue 3 中的确认密码字段存在问题。我的要求是使用密码字段检查确认密码,如果不匹配则发送错误。我为此使用了 vuelidate next 库。当用户与输入交互时,密码和确认密码字段会正确检查。但问题是当用户正确输入密码并确认密码字段并且再次用户更改密码字段验证不起作用时。它仅在用户交互输入时起作用。
这些是我的输入字段我如何使用 vuelidate
<Password
v-model.trim="v$.passwordConfirm.$model"
:feedback="false"
:class="{ 'p-invalid': v$.passwordConfirm.$error }"
@blur="v$.passwordConfirm.$touch()"
class="p-mb-1"
placeholder="Confirm Password"
toggleMask
>
</Password>
<template
v-for="(error, index) of v$.passwordConfirm.$errors"
:key="index"
>
<span v-if="v$.passwordConfirm.$error" class="p-error">{{error.$message}}</span>
</template>
这是我的验证方法
passwordConfirm: {
required: helpers.withMessage(
"Confirm password cannot be empty. ",
required
),
sameAsPassword: helpers.withMessage(
"Confirm password must be same as password you entered above.",
sameAs(dataAsRefs.password)
),
$lazy: true
},
解决方案
推荐阅读
- elasticsearch - ElasticSearch 将新的传入文档流式传输到客户端
- javascript - 7天后删除特定文件
- java - 当我使用 apache commons CLI 传递三个以上的选项时,结果显示为 NULL 第三个选项
- python - 生成新行并将它们附加到 DataFrame 的最快方法
- node.js - 当我在构建后运行我的 react 应用程序时,html 页面上没有显示任何内容。我该如何解决这个问题?
- excel - 基于Excel公式的VBA提取中间名
- python - 为什么我不能更改 python 窗口图标?
- java - Grails 启动失败 - 连接被拒绝
- firebase - Firebase verifyIdToken() 在缓存时是否需要为每个新令牌调用 Firebase API?
- countly-analytics - 配置 Count.ly 电子邮件