kazupon / vue-validator

:white_check_mark: Validator component for Vue.js
MIT License
2.19k stars 431 forks source link

Programmatically synchronized fields failed to trigger validation #251

Open nandin-borjigin opened 8 years ago

nandin-borjigin commented 8 years ago

vue & vue-validator version

1.0.24, 2.1.3

Reproduction Link

See jsfiddle

Steps to reproduce

  1. Enter something into one input field and click somewhere else to make it blur(lose focus)
  2. Another input field should be synchronized
  3. Empty one of them and then click somewhere else to make it blur
  4. All two input fields should be empty but only the manually-edited one triggers the validation

    Note

    • Only required rule is used, and if the field is untouched, we think it's acceptable to be empty, hence the .invalid.touched { border: red 1px solid; } css style.
    • Two input fields are synchronized programmatically, and in my project I use vuex so I achieve the synchronization in old-school way, instead of using v-model
    • Validation can't be grouped because in the actual project, the two fields need to be synchronized aren't on same component node.

      What is Expected?

When either of two input fields goes empty and loses focus , both of them should turn into invalid, because their values are synchronized.

What is actually happening?

Only the edited input field acts as expected, another one needs an extra interaction (e.g. click on it and then click somewhere else) to trigger validation

nandin-borjigin commented 8 years ago

I took a glance at commit0859cd and it seems that validation happens on input event and my problem here may need a validation on change event. Haven't dug deep enough to the source code though.

kazupon commented 8 years ago

Thank you for your reporting! I'll try to fix it.

nandin-borjigin commented 8 years ago

Hello @kazupon , is there any update on this problem?

kazupon commented 8 years ago

sorry, I can not see the light at this issue. 🙇 because I'm developing the vue-validator v3 for vue 2.0

nandin-borjigin commented 8 years ago

NP, just asking. :) Good luck