Blazor - Can we OnValidSubmit for every control change?
Hi,
I am looking to develop and application using Blazor. I have a standard form with a model. OnValidSubmit is currently being fired by a submit button. However, I am looking to submit the form on every change of any control on the form. Googling for an hour has not lead me to an answer. Does anyone have any pointers?
6 Replies
What do you mean by any control, on any input change?
InputText InputSelection any form element
What's the use case for this? Validation?
It is a search form. Results should only be searched for if all the fields are completed
You can wrap your form in edit context and subscribe to this event
https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.forms.editcontext.onfieldchanged?view=aspnetcore-8.0
EditContext.OnFieldChanged Event (Microsoft.AspNetCore.Components.F...
An event that is raised when a field value changes.
Thank you
Thank you. That was exactly what I needed.