Overview of the EditForm component
In the previous chapters of this book, we used the standard HTML form
element to collect user input. However, the Blazor WebAssembly framework provides an enhanced version of the standard HTML form
element called the EditForm
component.
The EditForm
component not only manages forms, it also coordinates both validation and submission events. The following code shows an empty EditForm
element:
<EditForm Model="expense" OnValidSubmit="HandleValidSubmit"> </EditForm>
In the preceding code, the Model
property specifies the top-level model object for the form. The OnValidSubmit
property specifies the callback that will be invoked when the form is submitted without any validation errors.
There are three different callbacks that are associated with form submission:
OnValidSubmit
OnInvalidSubmit
OnSubmit
We can use the OnValidSubmit
and OnInvalidSubmit
callbacks together...