Vuetify——校验密码和确认密码一致

<v-form v-model="valid" ref="form">
	<v-row no-gutters dense>
    <v-col cols="3" class="mt-2">
      <v-subheader
        ><span class="red--text">*</span>
        {{ $t("account.label.new_password") }}</v-subheader
      >
    </v-col>
    <v-col cols="9">
      <v-text-field
        rows="1"
        v-model="new_password"
        :placeholder="$t('account.placeholder.new_password')"
        :hint="$t('account.hint.password')"
        persistent-hint
        type="password"
        required
        :rules="rules.ispassword"
        style="margin-left:6px;"
      ></v-text-field>
    </v-col>
  </v-row>
  <v-row no-gutters dense>
    <v-col cols="3" class="mt-2">
      <v-subheader
        ><span class="red--text">*</span>
        {{ $t("account.label.confirm_password") }}</v-subheader
      >
    </v-col>
    <v-col cols="9">
      <v-text-field
        rows="1"
        v-model="confirm_password"
        :placeholder="$t('account.placeholder.confirm_password')"
        :hint="$t('account.hint.confirm_password')"
        persistent-hint
        type="password"
        required
        :rules="rules.isconfirm"
        style="margin-left:6px;"
      ></v-text-field>
    </v-col>
  </v-row>
</v-form>

export default{
	let isPassword = (value) => {
      let reg = /^(?![A-z0-9]+$)(?=.[^%&',;=?$\x22])(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).{8,20}$/;
      return reg.test(value);
    };
    let isConfirmPassword = (value) => {
      return this.new_password === value;
    };
	data(){
		valid: true,
		new_password: null,
      	confirm_password: null,
      	rules: {
        notNullRules: [(v) => !!v || "此项为必填项"],
        ispassword: [(v) => isPassword(v) ||"密码至少包含大小写字母+数字+特殊字符; 长度至少8位,最多20位。"],
        isconfirm: [(v) => isConfirmPassword(v) || "新密码与确认密码不一致"],
      },
	}
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值