10

How can I disable client-side form validation in my ASP.NET Core 1.1 app? But I need the server-side one.

0

3 Answers 3

13

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.

Sign up to request clarification or add additional context in comments.

2 Comments

@Octopus in my case is working properly on the first try. Are you sure about the Startup.cs configuration?
@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
8

you just remove the javascript for jquery.unobtrusive.validation.js

In the VS project templates that is in _ValidationScriptsPartial.cshtml

1 Comment

This solves part of the problem but still generates the data-val attributes instead of maxlength, required, etc.
4

In Razor Pages

services.Configure<HtmlHelperOptions>(o => o.ClientValidationEnabled = false);

See Disable client-side validation

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.