0

I want to validate a repeatable text field in vee-validate. At least one row of inputs should be filled. How can I achieve such kind of validation?

Here is shown how my repeatable text field looks like in the browser. When I click "+" a new row with inputs is added.

enter image description here

I will be very grateful for any help.

Mikołaj Waśniewski
  • 1,298
  • 14
  • 16
  • Sure, that seems possible? What did you try? Seems that if you give each input a unique name and apply v-validate as you would normally, it will work. – Ryley Mar 27 '19 at 20:57
  • But these fields are generated dynamically. And I want also to ensure that at least one row of fields is filled. – Mikołaj Waśniewski Mar 28 '19 at 12:14
  • Please check out the Stack Overflow FAQ - [This part specifically](https://stackoverflow.com/help/mcve). I suggest additionally you prepare an example perhaps using this as a template: https://codesandbox.io/s/x4kp93w3o – Ryley Mar 28 '19 at 15:36

1 Answers1

0

You can apply the required rule only in the first row. If you have v-for in your code, you can use track-by="$index" to track the first row, and conditionally apply the rule.

However, I think if you add a code example, it would be really useful to others to help you.

ATT
  • 337
  • 3
  • 10