Search code examples
asp.net-mvcvalidationclient-side-validation

Asp.net mvc client side validation - show errors in the same div


How do I list all generated errors in the same div?

Something like this:

<div id="errors">
  <ul>
    <li>Email is invalid</li>
    <li>Firstname is required</li>
  </ul>
</div>

Solution

  • Try using

    <%=Html.ValidationSummary()%>
    

    There is a section about it in this article: http://www.asp.net/mvc/tutorials/performing-simple-validation-cs