How to Hide or reset validation messages

Hello, I have a button that opens up a Modal that is in a seperate component. This gets triggered by clicking on a button and making it visible. Upon initialize, I instantiate the object DeliveryGroupModal. Not all the fields are set initially and it doesn't show the validation messages until you try to submit. But if I cancel out of the modal and open it up again, it brings up the validation messages.  Is there a way to hide them or make them show only when the user tries to submit the information. I just need to have it open up like it did the first time without displaying the validation messages. I have a video attached thanks.


   <DeliveryGroup OnClick="DeliveryGroupClickHandler" OnOk="DeliveryGroupOnOKHandler" Visibility="Visibility"></DeliveryGroup>


   <div class="row">
                            <div class="col-md-2"></div>
                            <div class="col-md-5"><Syncfusion.Blazor.Inputs.SfTextBox @bind-Value="DeliveryGroupModal.CustName" Readonly="true" CssClass="e-customTextSize"></Syncfusion.Blazor.Inputs.SfTextBox></div>
                            <div style="font-size : 12px">
                                <ValidationMessage For="@(() => DeliveryGroupModal.CustAccount)"></ValidationMessage>
                            </div>

                        </div>

Attachment: HideValidation_707fe389.zip

3 Replies 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team November 25, 2020 01:11 PM UTC

Hi Chris, 


Greetings from Syncfusion support. 


We checked the reported requirement. The reported requirement can be achieved by refreshing the model value in the dialog close event.  Refer to the below code, 


<EditForm Model="@model"> 
    <DataAnnotationsValidator /> 
    <SfDialog Width="250px" ShowCloseIcon="true" IsModal="true" @bind-Visible="@IsVisible"> 
        <DialogEvents Closed="OnClose"></DialogEvents> 
        <DialogTemplates> 
            <Content> 
                <Syncfusion.Blazor.Inputs.SfTextBox @bind-Value="@model.textVal"></Syncfusion.Blazor.Inputs.SfTextBox> 
                <ValidationMessage For="@(() => model.textVal)"></ValidationMessage> 
            </Content> 
        </DialogTemplates> 
        <DialogButtons> 
            <DialogButton Content="Save" IsPrimary="true" OnClick="@CloseDialog" /> 
            <DialogButton Content="Cancel" OnClick="@CloseDialog" /> 
        </DialogButtons> 
    </SfDialog> 
</EditForm> 
    public void OnClose(CloseEventArgs e) 
    { 
       model = new Model(); 
    } 



Please find the sample below, 




Please check the sample and let us know if you need further assistance. 
 

Regards, 
Sevvandhi N 


Marked as answer

CJ chris johansson November 25, 2020 03:58 PM UTC

Thanks that close method seemed to work with reseting the model


SN Sevvandhi Nagulan Syncfusion Team November 26, 2020 04:59 AM UTC

Hi Chris, 


Thanks for the update. Please let us know if you need further assistance. 


Regards, 
Sevvandhi N 


Loader.
Up arrow icon