Home > Back-end >  How to display client-side validation error without asp-validation-for?
How to display client-side validation error without asp-validation-for?

Time:10-03

I'm trying to customize the way the client-side validation is displayed on my form.

I don't want to use the asp-validation-for tags so they don't display with the control. I'd rather show these in the ValidationSummary control with the other errors or some other centralized place.

Is there a way to show the client-side model.field errors anywhere other than using a asp-validation-for tag?

CodePudding user response:

Use validation summary tag helper with attribute asp-validation-summary="All"

<form>
    <div asp-validation-summary="All"></div>
</form>

https://learn.microsoft.com/en-us/aspnet/core/mvc/views/working-with-forms?view=aspnetcore-6.0#the-validation-summary-tag-helper

  • Related