title: MVC-5 Razor Validation Errors showing on page load
body: <p>I have an insert page when I go to the insert page all the validation field is being shown,</p>
  
  <pre><code>[Required(ErrorMessage ="Please Enter Name")]
          public string ccname { get; set; }
  </code></pre>
  
  <p>This is my class where I declared string <code>ccname</code> with required validation message </p>
  
  <blockquote>
    <p>ENTER NAME</p>
  </blockquote>
  
  <p>and it supposed to appear when user clicks on insert without entering data in <code>ccname</code></p>
  
  <p>but validatation message is being shown on the page load</p>
  
  <pre><code>@Html.TextBoxFor(model =&gt; model.ccname, new { @class = "textboxstyle" })
  @Html.ValidationMessageFor(model =&gt; model.ccname)
  </code></pre>
  
  <p>I tried few things but nothing works,</p>
  
  <p>here is an example</p>
  
  <p>in my controller I added <code>ModelState.clear();</code></p>
  
  <pre><code>public ActionResult insert()
  {
      ModelState.Clear();
      return View();
  }
  </code></pre>
  
  <p>and in my view I changed the code from</p>
  
  <pre><code>@Html.TextBoxFor(model =&gt; model.ccname, new { @class = "textboxstyle" })
  @Html.ValidationMessageFor(model =&gt; model.ccname)
  </code></pre>
  
  <p>to</p>
  
  <pre><code>@Html.TextBoxFor(model =&gt; model.ccname, new { @class = "textboxstyle" })
  @Html.ValidationMessageFor(model =&gt; model.ccname,"",new {@style= ".validation-summary-valid { display:none; }" })
  </code></pre>
  
  <p>but neither of these works</p>
  
  <p>what should I do now?</p>