Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confirm not working as expected, when both fields are required. #1123

Closed
vsambor opened this issue Jan 23, 2018 · 4 comments
Closed

Confirm not working as expected, when both fields are required. #1123

vsambor opened this issue Jan 23, 2018 · 4 comments

Comments

@vsambor
Copy link

vsambor commented Jan 23, 2018

Description:
If I have the password as required and the confirmation as required... (because I don't want to allow form submittion if both are not filled) and when I start typing the password, the confirmation errors trigger directly.

It doesn't seems normal to trigger confirmation error when ever password field is dirty.

Code:

<q-card-main>
  <form>
    <!-- Email -->
    <q-field icon="mail" :error="errors.has('email')" :error-label="errors.first('email')">
      <q-input type="email" v-model="user.email" v-validate="'required|email'" name="email" :float-label="email" />
    </q-field>

    <!-- Password -->
    <q-field icon="lock" :error="errors.has('password')" :error-label="errors.first('password')">
      <q-input type="password" v-model="user.password" v-validate="'required|min:5'" name="password" :float-label="pass"></q-input>
    </q-field>

    <!-- Confirmation Password -->
    <q-field icon="lock" :error="errors.has('confirm_password')" :error-label="errors.first('confirm_password')">
      <q-input type="password" v-model="user.confirmPassword" v-validate="'confirmed:password|required'" name="confirm_password" :float-label="confirm"></q-input>
    </q-field>
  </form>
</q-card-main>

screen shot 2018-01-23 at 10 44 10 pm

As an example (http://element.eleme.io/#/en-US/component/form . Section Custom validation rules ) this is how it seams normal behavior.

Thank you for making this possible. (If you need more info, let me know)

@ismail9k ismail9k added 🤔 needs reproduction This issue requires a demo and removed 🤔 needs reproduction This issue requires a demo labels Jan 27, 2018
@ismail9k
Copy link

I think you can fix this problem by removing required rule from confirming password input since no need for it.

   <q-input type="password" v-model="user.confirmPassword" v-validate="'confirmed:password'" name="confirm_password" :float-label="confirm"></q-input>

Because the value of confirmPassword input should match the value of password input, so it will follow its rules by default which requierd|min:5

@vsambor
Copy link
Author

vsambor commented Jan 28, 2018

@abdelrahman3d I noted in the issue that I need to put required in order to prevent sending backend calls when the confirmation is not touched... In the case I don't put required, when I validate the form, it does not trigger any error and it allows to make backend calls, and this is what I want to avoid. It doesn't seems to take the password rules as you said. Thank you

@smares
Copy link

smares commented Apr 10, 2018

I can confirm that validateAll() does not trigger an error when the password has a value and the password confirmation is empty using only confirmed:password for the password confirmation field.

@logaretm logaretm closed this as completed Jun 3, 2018
@logaretm
Copy link
Owner

logaretm commented Jun 3, 2018

Closing due to the introduced changes in 2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants