Steven Muhr
Steven Muhr

Reputation: 3379

Disable Client Side Validation with ASP.NET 5

How to disable Client Side Validation with ASP.NET 5?

I tried to set ClientValidationEnabled to false in config.json like here but I still have data-val-* attributes in html elements.

Answer :

services.AddMvc()
        .ConfigureMvcViews(options =>
        {
           options.HtmlHelperOptions.ClientValidationEnabled = false;
        });

Upvotes: 6

Views: 3227

Answers (1)

Peter
Peter

Reputation: 12711

I don't believe configuring this via AppSettings is supported out of the box in ASP.NET 5. One option is to programmatically configure this in your Startup class's ConfigureServices method:

    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddMvc()
            .AddViewOptions(options =>
            {
                options.HtmlHelperOptions.ClientValidationEnabled = false;
            });

    }

The ClientValidationEnabled was moved to an HtmlHelperOptions property on MvcViewOptions.

Upvotes: 12

Related Questions