We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

OnTextChange event

I set ShowClearButton="true" on both EjsDatePicker and EjsTimePicker. OnChange event is not fired if I click on X "clear" icon.

I need OnTextChanged event which will be fired when text is changed (by a user input, copy, cut, paste etc).

4 Replies

GG Gopi Govindasamy Syncfusion Team September 25, 2019 08:56 AM UTC

Hi Andrey,  

Greetings from Syncfusion support.  
  
We would like to inform you that, we have provided ValueChange event, it will be fired when value has changed and also clicking "X" icon. Based on your requirement cut, copy, paste the text into input element, the ValueChange event will be triggered when the component focus out. The oninput event is fired immediately after the value of an element has changed. We have prepared sample based on your requirement for your reference. 

@using Syncfusion.EJ2.Blazor.Calendars; 
 
<EjsDatePicker ValueChange="DateChange" @oninput="OnTextChange"></EjsDatePicker> 
 
<p>@dateValue</p> 
 
<EjsTimePicker ValueChange="TimeChange" @oninput="OnTextChange"></EjsTimePicker> 
 
<p>@timeValue</p> 
 
@code{ 
 
    private DateTime? dateValue { get; set; } 
 
    private DateTime? timeValue { get; set; } 
 
 
    public void DateChange(ChangedEventArgs args) 
    { 
        dateValue = args.Value; 
    } 
 
    public void TimeChange(Syncfusion.EJ2.Blazor.Calendars.ChangeEventArgs args) 
    { 
        timeValue = args.Value; 
    } 
 
    public void OnTextChange(Microsoft.AspNetCore.Components.ChangeEventArgs args) 
    { 
        Console.WriteLine(args.Value); 
    } 
} 


Regards, 
Gopi G. 
 



MA Mr Andrey Voronov September 25, 2019 11:06 AM UTC

When I press on X, ValueChange event is triggered only if valid value is entered in text box

Enter invalid date/time "ab" in EjsDatePicker, click on X, neither ValueChange no OnInput are triggered


MA Mr Andrey Voronov September 25, 2019 11:38 AM UTC

Adding Text {get;set;} to EjsDatePicker and EjsTimePicker would make everything much easier


GG Gopi Govindasamy Syncfusion Team September 26, 2019 09:07 AM UTC

Hi Andrey, 

Thanks for your update.  

We would like to inform you that the ValueChange event triggered only when the valid date is entered in the DatePicker component. Your requirement is to listen to changes in some event even if the value you entered is not in the Date type. Based on your requirement, we will consider providing the "Cleared" event when the user clears the value using the"x" icon. It will fire on both invalid and valid date text removal action by clicking on the "X" icon. The event will be made available and the fix will be included on the upcoming release scheduled for mid-October 2019. You can track the status of this issue using a link below the feedback portal. 


If the above solution does not meet your requirements, please let me know your exact requirement with your actual use case in order to provide you with an accurate solution. 

Regards, 
Gopi G. 


Loader.
Live Chat Icon For mobile
Up arrow icon