7 Answer(s)
-
0
To enable client-side validation in an ABP MVC Core Razor Pages project, you must ensure that the required validation scripts are included in your layout. ABP's default layouts include these scripts, but if you use a custom layout, you need to add them manually.
Add the following lines before the closing </body> tag in your custom layout to enable client-side validation:
@section Scripts { <partial name="_ValidationScriptsPartial" /> }
Or, if your layout does not support sections, add directly:
<partial name="_ValidationScriptsPartial" />
Make sure your form includes the correct
asp-validation-summary
andasp-validation-for
tags, which you already have.Also, ensure that jQuery and the validation libraries are loaded. The
_ValidationScriptsPartial
partial includes these by default.If you use a custom error message key (e.g.,
"Validation:EmailRequired"
), ensure that your localization resources contain the corresponding translations.Example minimal layout addition:
<body> @RenderBody() <partial name="_ValidationScriptsPartial" /> </body>
- After these changes, client-side validation should work as expected for your form.
Sources:
- https://abp.io/docs/latest/framework/ui/mvc-razor-pages/forms-validation
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0
thanks but it is give me error InvalidOperationException: The partial view '_ValidationScriptsPartial' was not found. The following locations were searched: /Pages/_ValidationScriptsPartial.ar.cshtml /Pages/_ValidationScriptsPartial.cshtml /Pages/Shared/_ValidationScriptsPartial.ar.cshtml /Pages/Shared/_ValidationScriptsPartial.cshtml /Views/Shared/_ValidationScriptsPartial.ar.cshtml /Views/Shared/_ValidationScriptsPartial.cshtml
-
0
hi
why client validation not working in web public project mvc core razor
Can you explain it in detail? share some screenshots.
Thanks.
-
0
I solved it by making this
I moved @RenderSection("scripts", required: false) from header tag to be before closed body tag and also add <!-- ✅ jQuery Validation and Unobtrusive --> <script src="~/libs/jquery-validation/jquery.validate.js"></script> <script src="~/libs/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script> and also make inputs like this
<div class="form-group form-group__container"> <label for="Name" class="control-label"> <span class="text-danger">*</span> @L["Name"] </label> @Html.TextBoxFor(m => m.Name, new { @class = "form-control", placeholder = @L["NamePlaceholder"] }) @Html.ValidationMessageFor(m => m.Name, "", new { @class = "text-danger" }) </div>
Thanks
-
0
Great 👍
-
0
[maliming] said: Great 👍
thanks for your response and support
-
0
: )