I am new to knockout js. I need to have a validator for date which user will be typing in textbox. for this wrote the code like
ko.validation.rules['date'] = {
validator: function (value, validate) {
//Custom logic
},
message: 'Please type proper date'
};
self.userDate = ko.observable(new Date()).extend({date: true });
This is working fine on tab out. But i need to call this validation on some delay(When the user stopped typing).
Any one could tell me how can i call this validation on delay?
To make sure the viewmodel is updated as the user is typing, use the
valueUpdatebinding:<input data-bind="value: userDate, valueUpdate: 'afterkeydown'" />You then throttle the observable:
Throttle in this case waits 1000 ms after the last registered input event to perform the validation.