title: Html.ValidationSummary always showing
body: <p>I have a View which has a couple of required fields - however the ValidationSummary message should be triggered when the user clicks "Add" not when the page loads.</p>
  
  <p>I have tried below link but these results in the ValidationSummary dissapearing altogether...</p>
  
  <p><a href="https://stackoverflow.com/questions/21296281/mvc-razor-validation-errors-showing-on-page-load-when-no-data-has-been-posted">MVC Razor Validation Errors showing on page load when no data has been posted</a></p>
  
  <pre><code>public ActionResult Index(ParticipantViewModel p)
      {
          if (p.ClientName != null)
          {
                  string[] split = p.ClientName.Split(',');
  
                  p.ClientName = split[0];
                  p.ClientConn = split[1];
                  d.Connection.ConnectionString = p.ClientConn; 
  
                  var prt = d.Participants.Where(s =&gt; s.Id == p.Id).FirstOrDefault();
  
                  if (prt != null)
                  {
                      p.FirstName = prt.FirstName;
                      p.LastName = prt.LastName;
                      p.PayrollNo = prt.PayrollNo;
                      p.Id = prt.Id;
                  }
  
                  //ModelState.Clear();
                  return View(p);
          }
          else
          {
  
              return RedirectToAction("SearchParticipants");
          }
      }
  </code></pre>
  
  <p>Code in View:-</p>
  
  <pre><code>@Html.ValidationSummary("", new { @class = "validation-summary-valid text-danger" })
  @using (Html.BeginForm("Add", "Participants", FormMethod.Post, new {@class = "form-horizontal", role =""}))
  {
    @Html.AntiForgeryToken()
    &lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.FirstName)&lt;/th&gt;
          &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.LastName)&lt;/th&gt;
          &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.PayrollNo)&lt;/th&gt;
          &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.TransDesc)&lt;/th&gt;
          &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.Points)&lt;/th&gt;
          &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.Actions)&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;@Html.DisplayFor(model =&gt; model.FirstName)&lt;/td&gt;
          &lt;td&gt;@Html.DisplayFor(model =&gt; model.LastName)&lt;/td&gt;
          &lt;td&gt;@Html.DisplayFor(model =&gt; model.PayrollNo)&lt;/td&gt;
          &lt;td&gt;@Html.TextBoxFor(model =&gt; model.TransDesc)&lt;/td&gt;
          &lt;td&gt;@Html.TextBoxFor(m =&gt; m.Points, new { onkeydown = "return ValidateNumber(event);"})&lt;/td&gt;
          &lt;td&gt;@Html.EnumDropDownListFor(model =&gt; model.Actions)&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  
      if (Model.FirstName != null)
      {
          &lt;div class="form-actions no-color"&gt;
              &lt;input type="submit" value="Add" class="btn btn-primary"/&gt;
          &lt;/div&gt;
      }
  }
  @section Scripts {
  
  &lt;script type="text/javascript" language="javascript"&gt;
      function ValidateNumber(e) {
          var evt = (e) ? e : window.event;
          var charCode = (evt.keyCode) ? evt.keyCode : evt.which;
          if (charCode &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57) &amp;&amp; (charCode &lt; 96 || charCode &gt; 105))
          {
              return false;
          }
          return true;
      };
  &lt;/script&gt;
  @Scripts.Render("~/bundles/jquery")
  @Scripts.Render("~/bundles/jqueryval")
  }
  </code></pre>
  
  <p>Site.Css</p>
  
  <pre><code>.validation-summary-valid
  {
  display:none;
  }
  </code></pre>
  
  <p>Sreenshot of View without the Add button being clicked:-</p>
  
  <p><a href="https://i.stack.imgur.com/9cqGN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9cqGN.png" alt="View looks like this"></a>
  What am I missing?</p>