How can I disable client-side form validation in my ASP.NET Core 1.1 app? But I need the server-side one.
3 Answers
You do this in your ConfigureServices class in your Startup file:
services.AddMvc().AddViewOptions(options =>
options.HtmlHelperOptions.ClientValidationEnabled = false);
This will work for the attributes generated by tag helpers.
2 Comments
T-moty
@Octopus in my case is working properly on the first try. Are you sure about the Startup.cs configuration?
Octopus
@T-moty this has been solved in a recent update of .Net Core, so probably you use such a version. See github.com/aspnet/AspNetCore/issues/7576
you just remove the javascript for jquery.unobtrusive.validation.js
In the VS project templates that is in _ValidationScriptsPartial.cshtml
1 Comment
Xavier Poinas
This solves part of the problem but still generates the
data-val attributes instead of maxlength, required, etc.In Razor Pages
services.Configure<HtmlHelperOptions>(o => o.ClientValidationEnabled = false);