Disable validation of component

Hello,

I would like to know if it is possible to disable validation in Syncfusion components such as SfTimePicker?
We are using custom CSS (based on Bootstrap 5) to achieve a certain look which means we have to style Syncfusion components as well which makes every Syncfusion Blazor release interesting for us.. :)

Anyway, a few versions ago Syncfusion changed how validations are shown and we get a ugly (in our opinion) green checkmark next to Timepicker.
Is there a way to override this behavior in Blazor or are we forced to hide these using CSS techniques?

4 Replies 1 reply marked as answer

BC Berly Christopher Syncfusion Team May 20, 2021 08:22 AM UTC

Hi Jasmin, 
  
Greetings from Syncfusion support. 
  
We would like to inform you that, while validating the Syncfusion TimePicker component, there is no checkmark will be added to the component. We have added the error and green border for intimating the error and success validation. For your convenience, we have attached the screenshot for TimePicker on validation. 
  
Screenshot: 
  
Error validation 
Success validation 
 
 
 
  
  
So, please share any code snippet or issue reproducing sample along with issue screenshot that will help us to check and proceed further from our end. 
  
Regards, 
Berly B.C 



JA Jasmin May 23, 2021 09:38 AM UTC

Hello, shows up on our end at least:


Anyway, that is not the point of my forum thread but the question is if there a way to turn off or control validation of your controls?
 


BC Berly Christopher Syncfusion Team May 24, 2021 12:38 PM UTC

Hi Jasmin, 
  
By default, data annotation works based on Required attribute of the model property, if you can remove attribute, the validation message is not shown. The component success or failure class is updated based on the ValueExpression and EditContext. In application level, you can set the null to the ValueExpression to remove the form validation for the specific control. Please find the modified code snippet for your reference.  
  
@using Syncfusion.Blazor.Calendars 
@using System.ComponentModel.DataAnnotations 
@using System.Linq.Expressions; 
 
<EditForm Model="@model" OnValidSubmit="@SavePatient"> 
    <DataAnnotationsValidator /> 
    <SfTimePicker TValue="DateTime?" Value="@model.timeval" ValueChanged="@((DateTime? val) => model.timeval = val)" ValueExpression="@exp"></SfTimePicker> 
    <ValidationMessage For="() => model.timeval" /> 
    <button type="submit">Submit</button> 
</EditForm> 
@code{ 
    public class TimeModel 
    { 
        //[Required(ErrorMessage = "Time Value is required")] 
        public DateTime? timeval { get; set; } 
    } 
    public Expression<Func<DateTime?>> exp; 
    TimeModel model = new TimeModel(); 
    public void SavePatient() 
    { 
 
    } 
 
} 
 
  
  
Regards, 
Berly B.C 


Marked as answer

JA Jasmin May 25, 2021 02:05 PM UTC

Thanks a bunch, will try it out!

Loader.
Up arrow icon