0

I am creating an application in MVC4. I have a validationsummary on my page as follows,

<div>
            @Html.ValidationSummary()
        </div>

when the page loads, it shows the validation summary and says one of the required fields is required. Why is this shown on load? I thought the validation summary was only shown after a submit?

thanks

<div id="GeneratePaymentContainer" class="content-container">
       <div>
            @Html.ValidationSummary()
        </div>
    <div id="GeneratePaymentPage1">

        <div id="PageHeaderContainer">
            <div id="HelpContainer">
                <h2>@SearchPayment.SearchPlacementsHeader</h2>
                @Html.PageHelp()
            </div>


            @{ Html.RenderPartial("PlacementFilter", Model); }
        </div>
        <div id="BodyContainer">
            <div id="GridActions" class="buttons-container">
                <a id="Print" class="button">@Buttons.PrintButton</a>
            </div>

            @{ Html.RenderPartial("SearchGridResults", Model); }
            <div id="StandardCost"></div>


            <div id="SelectedPlacementContainer"></div>

            <br />
        </div>
    </div>

    @using (Html.BeginForm("RequestAction", "Request", FormMethod.Post, new { id = "SundryEntryForm" }))
    {

}...
user2206329
  • 2,792
  • 10
  • 54
  • 81

1 Answers1

1

try to write your @Html.ValidationSummary() before Html.BeginForm tag

Update : According to this Post Therefore, just create a css rule as follows;

.validation-summary-valid
{
display:none;
}
Community
  • 1
  • 1
Nilesh Gajare
  • 6,302
  • 3
  • 42
  • 73