Reputation: 9411
I am using model binding (with a strongly typed partial view) for my validation of a search form.
For a "live" search I require city, date, time and other things, but for a "city" I only require city.
Is there a way to set the required attribute on my model conditionally, based on whether a hidden input "searchtype" is set?
Or is model binding, not going to work in this situation?
Upvotes: 0
Views: 479
Reputation: 125488
Out of the box, there isn't any kind of RequiredIfAttribute
, but MVC FoolProof validation has these plus many other useful validation attributes.
Upvotes: 1