Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple partials means that model errors bleed between forms

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>
like image 637
BanksySan Avatar asked Jun 18 '26 06:06

BanksySan


1 Answers

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.

like image 136
glautrou Avatar answered Jun 19 '26 23:06

glautrou