I am using EF4 and ASP.NET MVC 2 for my web application. I am also using data annotations for my validation.
Is the following possible? If so, how would I implement it? I have a checkbox, and a from and to date. The from and to date are not required fields, but when the checkbox is ticked then the from and to dates are required fields. Then the required error must display.
How is this possible?
Thanks.
You need to create a validation attribute for the model class itself that validates the three fields.
For an example, look at the
[FieldsMustMatch]attribute in the default MVC project template.