Reputation: 4893
I have two checkboxes that I'm adding a simple custom validator on. I want to check that either one or the other (or both) are checked, but that they aren't both empty.
To do this, I've written put a simple unless checkbox1 || checkbox2 line in my custom validator method. However, when outputting the error message, I realized that the error.add takes the form field as first parameter. I don't want the error message to be specifically for one of the other checkbox; I just want it to say, one or both need to be selected. How can I do this?
Upvotes: 0
Views: 62