0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Vue.js]パスワードとパスワード確認をチェックするフォームのバリデーション

Last updated at Posted at 2019-06-05

やりたいこと

表題の通り、こういった、何かと何かを比較して
判定するよくあるフォームのバリデーション

前提として、veevalidateというプラグインを使用しております。

今後よく使いそうなので簡単にメモ

スクリーンショット 2019-06-05 11.37.41.png

やったこと

 <the-heading02 :title="'パスワード再発行'" />
    <div class="c-input-text__wrap">
      <div class="input__wrap">
        <base-input
          ref="email"
          v-model="email"
          v-validate="'required|email|max:256'"
          :placeholder="'メールアドレス'"
          name="email"
          data-vv-as="このメールアドレス"
          class="first_input"
          :class="{ 'has-error': errors.has('email') }"
        />
        <base-input
          v-model="re_email"
          v-validate="'required|email|max:256|confirmed:email'"
          :placeholder="'メールアドレス確認用'"
          name="re_email"
          data-vv-as="このメールアドレス"
          class="second_input"
          :class="{ 'has-error': errors.has('re_email') }"
        />
      </div>

      <!-- ERRORS -->
      <div v-show="errors.any()" class="validate__area">
        <div v-if="errors.has('email')">
          <p class="alert-danger">
            {{ errors.first('email') }}
          </p>
        </div>
        <div v-if="errors.has('re_email')">
          <p class="alert-danger">
            {{ errors.first('re_email') }}
          </p>
        </div>
      </div>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?