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

DatePicker OnChange event not firing when changing invalid javascript date.

Hi.

We're currently in a situation where we want to alert the user why the date they have entered is being altered after it has been edited.

In the attached playground we can see the event fire in the console when we select from the list or we enter a valid date 01/01/2000

we get the event when we enter an out of range date (01/01/1969)

However we do not get the event when we enter 0000000000 or any other non-date value other than an empty input box which passes null as the value.

http://jsplayground.syncfusion.com/lushiwoh


Is there another event that fires before the value of the input is updated to the old/valid value?

1 Reply

FP Francis Paul Antony Raj Syncfusion Team April 27, 2016 01:20 PM UTC

Hi Robert, 
 
Thanks for contacting Syncfusion support. 
 
Query: Is there another event that fires before the value of the input is updated to the old/valid value when we enter 0000000000 or any other non-date value other than an empty input box which passes null as the value? 
 
We have analyzed your query and checked the provided code example. By default ‘enableStrictMode’ property is set as false in ejDatePicker component. In this scenario, while you tried to enter the invalid date in textbox, model value doesn’t get changed/updated and it maintains the previous valid date only. So, in that case ‘change’ event doesn’t raised. 
Note: “change” event raises only whenever the model value get changed. 
If you have set ‘minDate’ property in DatePicker, and enter a valid date in textbox which is less than minDate, then the Date has been set to ‘minDate’ value and hence ‘change’ event raises. 
 
If you have set ‘enableStrictMode’ as true, you can enter the invalid date in the textbox. In this case entering invalid date causes, 
#1) error class (‘. e - error’) will get added to wrapper to highlight the invalid date. 
#2) model value changed from valid date to null (change event raises) 
 
For more information about enableStrictMode in DatePicker, Please refer to http://help.syncfusion.com/js/datepicker/behavior-settings#strict-mode 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Francis Paul A 


Loader.
Live Chat Icon For mobile
Up arrow icon