My model contains a collection:
public ICollection<int> ChildAges { get; set; }
This is a dynamic list of ages that can be added to, this is all controlled via JQuery.
giving me
<select name="ChildAges">...</select>
<select name="ChildAges">...</select>
<select name="ChildAges">...</select>
etc...
If I add the standard Required
attribute the validation returns true if any one value in the collection is set.
How can I validate that all ChildAges
in the form are set?
I created a new custom
IClientValidatable
attribute:and applied this to my model:
I can then add the JQuery side:
Note this also returns true if the element isn't visible