Welcome to the Blazor feedback portal. We’re happy you’re here! If you have feedback on how to improve the Blazor, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
Native onchange event in DatePicker component is not triggered after click the clear icon
Sample:
Replication procedure:
1. Run the above sample.
2. Clear the input value using backspace key and type “10081994” and click outside.
3. The native change event is triggered and the output will be 10/08/1994.
4. Now clear the input value using clear icon and type “10081994” and click outside.
5. The change event is not triggered and the input is not parsed.
@using System.Globalization;
<SfDatePicker TValue="DateTime?" Value='@DateValue' Min='@MinDate' Max='@MaxDate' @onchange="@OnChange" Format="MM/dd/yyyy" ShowClearButton></SfDatePicker>
@code {
public DateTime? DateValue { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 10);
public DateTime MinDate { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 05);
public DateTime MaxDate { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 27);
public void OnChange(ChangeEventArgs args)
{
DateTime parsedDate;
var result = DateTime.TryParseExact(args.Value.ToString(), "MMddyyyy", new CultureInfo("en-US"),
DateTimeStyles.None, out parsedDate);
if (result)
{
DateValue = parsedDate;
}
}
}