Why does the ValidationSummary show up even though the ModelState is valid?
Asked Answered
C

1

7

I have a view with @Html.ValidationSummary("Please check the following errors:") at the top of a form. The text "Please check the following errors:" is always rendered, whether or not the model state is valid (I have verified the model state both in the view and in the controller).

Can anyone point me to why this is happening? I feel like I'm missing something pretty basic here - but I'm stumped!

Conceptionconceptual answered 27/8, 2011 at 20:22 Comment(0)
C
11

Uh - I just realised why. It was because I'd removed the default styles for the validation summary! Adding this back in solved my issue:

.validation-summary-valid
{
    display: none;
}

D'oh!

Conceptionconceptual answered 27/8, 2011 at 20:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.