Data-val-* attribute
A data-val-* attribute is an HTML data attribute convention for encoding validation metadata used by unobtrusive client-side validation.
Pro ASP.NET Core 7, Tenth Edition
A data-val attribute is an HTML data attribute emitted by ASP.NET Core to provide client-side validation metadata.
- How it is used
- Supplies HTML metadata that unobtrusive JavaScript uses to validate form fields before submission.
- How deep it goes
- Shows generated attributes and the scripts that consume them, but does not detail the JavaScript validator’s internals.
- Examples
- Uses generated ProductId and Name inputs, validation script listings, and an F12 check for absent HTTP requests.
- What you can do after
- Apply it via jQuery Validation and jQuery Validation Unobtrusive to display form errors without submitting invalid data.
Read how Pro ASP.NET Core 7, Tenth Edition explains data-val-* attribute →
ASP.NET Core in Action, 3e
A data-val-* attribute is an HTML attribute convention that encodes validation metadata for unobtrusive client-side validation libraries.
- How it is used
- Supports unobtrusive client-side validation by carrying DataAnnotations constraints from generated form fields to JavaScript libraries.
- 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 you can do after
- Apply it via generated form markup and validation libraries to provide immediate feedback for invalid field values.
Read how ASP.NET Core in Action, 3e explains data-val-* attribute →
Related concepts
- 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.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

