- June
Posted By : Alexander Goida
Adding client-side validation to custom Editor Templates in MVC

When an editor template is overridden with custom one you lose automatic scaffolding of client-side validation which uses data annotation rules. In such a case they should be added manually to your templates.

In the beginning of HTML form you should add  @Html.ValidationSummary(true). The parameter excludePropertyErrors = true because I don’t want to mix up error for properties with other model errors.

For each property in your HTML markup you should add special extension @Html.ValidationMessageFor(…)



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.