web.config中配置
<appSettings> <add key="webpages:Version" value="3.0.0.0" /> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings>
https://github.com/aspnet/jquery-validation-unobtrusive
Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.
The jQuery Unobtrusive Validation library complements jQuery Validation by adding support for specifying validation options as HTML5 data-*
elements.
This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the Home repo.
Remember to make your changes to only the src file. Use ".uild.cmd" to automatically generate the js file in dist directory, minify the js file, create a .nupkg and change the version in the package.json if needed.
To stage for a release, update the "version.props" file and run ".uild.cmd" (see Release Checklist here).
Brad Wilson has a couple great articles on unobtrusive validation and unobtrusive ajax.
It is also shown very nicely in this Pluralsight video in the section on " AJAX and JavaScript".
Basically, it is simply Javascript validation that doesn't pollute your source code with its own validation code. This is done by making use of data-
attributes in HTML.