Hi @Ahmed Salah Abed Elaziz ,
How to reset validation when open new modal bootstrap to add New Server, you can refer to below:
1.Add @onclick="OnInitialized"
in your close/X button,
<button type="button" style="background-color: white !important;" @onclick="OnInitialized" data-dismiss="modal">X</button>
2.Change you EditForm to use EditContext
<EditForm EditContext="editContext" OnValidSubmit="Submit" >
- Add the
HandleValidationRequested
handler method clears any existing validation messages by calling ValidationMessageStore.Clear before validating the form.
@code{
private ServerNames sn = new ServerNames();
private EditContext? editContext;
private ValidationMessageStore? messageStore;
private void Submit()
{
Console.WriteLine($"{sn.Server_Name},{sn.ServerID}");
}
protected override void OnInitialized()
{
editContext = new(sn);
editContext.OnValidationRequested += HandleValidationRequested;
messageStore = new(editContext);
}
private void HandleValidationRequested(object? sender,
ValidationRequestedEventArgs args)
{
messageStore?.Clear();
}
}
4.result:
-
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Qing Guo