liveBook · Manning

Data-val-* attribute

A data-val-* attribute is an HTML data attribute convention for encoding validation metadata used by unobtrusive client-side validation.

How 2 Manning books explain it

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

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.