I am using ko binding for my date time picker. I got a sample from here
But when user enters invalid data the value is resetting to today’s date. How to avoid this?
(I need to show the field as invalid. Since it is resetting it always shows me valid)
This isn’t due to knockout. This is the default behaviour of the jQuery DatePicker.
When an invalid date is entered, the result of
$(element).datepicker('getDate')is today’s date.See here for solutions to check if the current input of a jQuery DatePicker is valid. Then modify the
ko.utils.registerEventHandlercall in your custom-binding like so: