jwaliszko / ExpressiveAnnotations

Annotation-based conditional validation library.
MIT License
351 stars 123 forks source link

Need to use RequiredIf on a conditional based on checkbox list #192

Open samgiordano opened 6 years ago

samgiordano commented 6 years ago

I have 3 checkboxes with the same Name field and each with a different ID field. This creates the value of the field as a comma separated string. Each checkbox has a conditional textbox they need to fill in if checked.

I tried using a RequiredIf on the textbox field using Contains on the Name of the checkbox field but it doesn't fire.

Its setup like this in my viewmodel:

`public string Three_Checkboxes { get; set; }

[RequiredIf("Contains(Three_Checkboxes, 'This is the value of checkbox one')", ErrorMessage = " * required")] public string Checkbox_One_Textbox { get; set; }`

Any ideas what I can do to make this work?

Thanks!