A data-val-* attribute is an HTML attribute convention that encodes validation metadata for unobtrusive client-side validation libraries.
A data-val-* attribute encodes validation metadata on generated form fields. Client-side validation libraries read this metadata to provide immediate feedback when entered values violate DataAnnotations constraints. section 18.2.3
Generated email validation
An email field can render data-val="true", data-val-email with an error message, and data-val-required with a required-field message. jQuery Validation and its unobtrusive adapter consume these attributes when their scripts are included. section 18.2.3
How ASP.NET Core in Action, 3e covers it
How deep it goes
Explains generated validation attributes and required scripts, but does not descend into library internals or custom rule implementation.
Examples
Shows an email input with data-val-email and data-val-required metadata, plus script references for unobtrusive validation.
What it assumes
Assumes generated form fields and DataAnnotations, while demonstrating the required validation scripts and their purpose.
What you can do after
Apply it via generated form markup and validation libraries to provide immediate feedback for invalid field values.
How it connects
Connects DataAnnotations, client-side validation, jQuery, Razor Pages, Tag Helpers, and model binding.
dataannotations attributeproduced by · A DataAnnotations attribute is a .NET attribute that declares metadata or validation rules for types, members, and data-model elements.
validationuses · The process of checking data, behavior, systems, models, or results against defined criteria to assess their correctness, suitability, or acceptability.
unobtrusive validationused by · Unobtrusive validation is a client-side validation approach that represents rules in HTML data attributes and processes them through separate scripts.
attributekind of · A programming-language attribute is declarative metadata associated with a program element that provides information or directives to compilers, tools, frameworks, or runtimes.
This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.