-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
All checkboxes of a checkbox group mandatory #4739
Comments
Use |
Hello @hanzelkatomas, https://stackblitz.com/edit/vee-validate-v4-checkboxes-r4z6y5?file=src%2FApp.vue |
Follow this example: You have to use different names for different inputs. Also each input should have it's own error message component. |
@hanzelkatomas In my usecase I have to use the same name (which is possible with HTML5 and VeeValidate), that's why I specifically asked for help with the same name. In my case I cannot use |
If you are going to use same name for multiple inputs, then vee-validate is going to treat them as one input (if all checkboxes have the same "value" attribute). Then if you check one checkbox, the other checkboxes with the same name are gonna be checked. It's expected that different inputs have different name and you should implement your form with that in your mind. If you really need have the same name property (which you shouldn't), then you can try this validation: |
Thanks for helping! I think you are talking none sense for checkbox names though, it is completely possible to have the same name for different checkbox. It is possible with native HTML and VeeValidate, so there no reason I "shouldn't use this". |
It seems my usecase evolved so the |
@hanzelkatomas is correct, vee-validate assumes they are all part of the same group so they would be represented as an array and But if you plan to have some as being mandatory and some as being required, like cookies preferences kind of form then you would need to represent it differently. Give each field a unique name, for example This means each would be treated as an individual field but I think thats a more accurate representation of them, alternatively split the groups into required and non-required ones with unique name for each set. I think this is for userland to handle as there are many ways to go about it, I will close it for now but feel free to ask for more clarification with what you've tried so far in a demo if possible. |
Is your feature request related to a problem? Please describe.
I'm trying to find a way with "Components" approach to be able to validate when a group of checkboxes with same name have been checked. Currently the
rules="required"
is checking that at least one checkbox is checked. Is there an easy way to check that all checkboxes of the group are checked?Describe the solution you'd like
Is there an option to make all fields of a group mandatory? Something like
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: