How can I disable client-side form validation in my ASP.NET Core 1.1 app? But I need the server-side one.
We can enable and disable the client-side validation by setting the values of ClientValidationEnabled & UnobtrusiveJavaScriptEnabled keys true or false. This setting will be applied to application level. For client-side validation, the values of above both the keys must be true.
Model state represents errors that come from two subsystems: model binding and model validation. Errors that originate from model binding are generally data conversion errors. For example, an "x" is entered in an integer field.
The ASP.NET core includes unobtrusive client-side validation libraries, which makes it easier to add client side validation code, without writing a single line of code. In the previous tutorial on server side validation, we looked at how data annotations attributes are used by the Model Validator to validate the Model.
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.
you just remove the javascript for jquery.unobtrusive.validation.js
In the VS project templates that is in _ValidationScriptsPartial.cshtml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With