I have two partials on a page, both are have forms in them.
@{
Html.RenderPartial("LogIn", Model.EmailAuthenticationViewModel);
Html.RenderPartial("Register", Model.RegistrationViewModel);
}@
When I submit a form in an error state (e.g. no email address), the validation errors appear on both partials.
How can I restrict validation errors to only the errors caused by that partial?
For example
Both partials have a field for an email address. When one of the partial's forms is submitted without the email address, the validation error appears on both form's input boxes.
Both forms define the text box in the standard manner:
@Html.TextBoxFor(m => m.Email)
<div class="validation-summary-error" role="alert">
@Html.ValidationMessageFor(m => m.Email)
</div>
Your problem is very similar to this question: Specify validation summary on multiple forms.
Mandoleen shared this blog post Multiple validation summary at single page.
Please check and tell us if it doesn't fix your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With