--- title: Blazor forms and validation author: guardrex description: Learn how to use forms and field validation scenarios in Blazor. monikerRange: '>= aspnetcore-3.0' ms.author: riande ms.custom: mvc ms.date: 04/15/2019 uid: blazor/forms-validation --- # Blazor forms and validation By [Daniel Roth](https://github.com/danroth27) and [Luke Latham](https://github.com/guardrex) Forms and validation are supported in Blazor using [data annotations](xref:mvc/models/validation). > [!NOTE] > Forms and validation scenarios are likely to change with each preview release. The following `ExampleModel` type defines validation logic using data annotations: ```csharp using System.ComponentModel.DataAnnotations; public class ExampleModel { [Required] [StringLength(10, ErrorMessage = "Name is too long.")] public string Name { get; set; } } ``` A form is defined using the `` component. The following form demonstrates typical elements, components, and Razor code: ```csharp @functions { private ExampleModel exampleModel = new ExampleModel(); private void HandleValidSubmit() { Console.WriteLine("OnValidSubmit"); } } ``` * The form validates user input in the `name` field using the validation defined in the `ExampleModel` type. The model is created in the component's `@functions` block and held in a private field (`exampleModel`). The field is assigned to the `Model` attribute of the ``. * The Data Annotations Validator component (``) attaches validation support using data annotations. * The Validation Summary component (``) summarizes validation messages. * `HandleValidSubmit` is triggered when the form successfully submits (passes validation). A set of built-in input components are available to receive and validate user input. Inputs are validated when they're changed and when a form is submitted. Available input components are shown in the following table. | Input component | Rendered as… | | ----------------- | ------------------------- | | `` | `` | | `` | `