We are facing a scenario..here it is:
Our Customer Model has collection of Address object. The form displays 3 address for the customer for their input. However only the first address is mandatory. Now our Validation is on the Address Model, something like, "street address cannot be null".
So when the form is submitted, the validation is executed on all the 3 address, even though the second and third address is not mandatory, the validation summary displays the message that "Street address 1 cannot be null" twice.
So how can we make this validation for second and third address optional ? like it validation executes only if the customer enters the second and third address. We want to use only the server side validation.
Or Is there a way in controller that we remove the error message from Model State and forcefully make ModelState.IsValid to true ?