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

Multiple fields in one <validate> block? #133

Open
jezmck opened this issue May 11, 2020 · 1 comment
Open

Multiple fields in one <validate> block? #133

jezmck opened this issue May 11, 2020 · 1 comment

Comments

@jezmck
Copy link

jezmck commented May 11, 2020

I'd like to have 3 validated inputs and have all their errors appear in the same place, after all the inputs.

Minimal replication: https://codepen.io/jezmck/pen/oNjyXBm

Only one of the inputs is validated, kinda. The message for the first input can appear when the second is invalid etc.

I don't know whether I'm missing something, but why is the name attributes mandatory available if there can only be 1 <field-messages> tag per <validate> tag?

@jezmck
Copy link
Author

jezmck commented May 11, 2020

BTW, the only way I've found to achieve what I want is to have duplicate but hidden fields underneath the real ones:

<validate>
  <input class="hidden" v-model="model.dob.d" name="dob-d" required>
  <field-messages name="dob-d">
    <div slot="required">Please enter your birth date</div>
  </field-messages>
</validate>
<validate>
  <input class="hidden" v-model="model.dob.m" name="dob-m" required>
  <field-messages name="dob-m">
    <div slot="required">Please enter your birth month</div>
  </field-messages>
</validate>
<validate>
  <input class="hidden" v-model="model.dob.y" name="dob-y" required>
  <field-messages name="dob-y">
    <div slot="required">Please enter your birth year</div>
  </field-messages>
</validate>

but this doesn't get the required styling on the visible inputs.

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

1 participant