使用element-plus 完成密码再次验证(修改密码)

show-password:密码的显示和隐藏

 

 

 

	
			<el-form ref="ruleFormRef" :model="editPosswordForm" :rules="rules" label-width="80px">
				<el-form-item label="旧密码" prop="password">
					<el-input v-model="editPosswordForm.password" show-password/>
				</el-form-item>
				<el-form-item label="新密码" prop="newPassword">
					<el-input v-model="editPosswordForm.newPassword" show-password/>
				</el-form-item>
				<el-form-item label="确认密码" prop="confirm">
					<el-input v-model="editPosswordForm.confirm" show-password/>
				</el-form-item>
			</el-form>
			<template #footer>
				<span class="dialog-footer">
					<el-button @click="resetForm">取消</el-button>
					<el-button type="primary" @click="submitForm(ruleFormRef)">
						提交
					</el-button>
				</span>
			</template>
	

 

 

const equalToPassword = (rule: any, value: any, callback: any) => {
	if (editPosswordForm.value.newPassword !== value) {
		callback(new Error("两次输入的密码不一致"));
	} else {
		callback();
	}
};

//验证规则

const rules = reactive<any>({
	password: [
		{ required: true, message: '请输入旧密码', trigger: 'blur' },
	],
	newPassword: [
		{ required: true, message: '请输入新密码', trigger: 'blur' },
	],
	confirm: [
		{ required: true, trigger: "blur", message: "请再次输入您的密码" },
		{ required: true, validator: equalToPassword, trigger: "blur" }
	],

})

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值