---
title: ASP.NET Core 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: 09/23/2019
uid: blazor/forms-validation
---
# ASP.NET Core 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).
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 `EditForm` component. The following form demonstrates typical elements, components, and Razor code:
```csharp
@code {
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 `@code` block and held in a private field (`exampleModel`). The field is assigned to the `Model` attribute of the `` element.
* The `DataAnnotationsValidator` component attaches validation support using data annotations.
* The `ValidationSummary` 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… |
| --------------- | ------------------------- |
| `InputText` | `` |
| `InputTextArea` | `