This is a migrated thread and some comments may be shown as answers.

DatePicker change event after clear textbox

2 Answers 1420 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Claudia
Top achievements
Rank 1
Claudia asked on 08 May 2019, 03:55 PM

Hi

I'm trying to enable/disable a button base on the datepicker value. If I pick the value from the calendar the change event triggers perfectly fine but if I clear the textbox selecting the value and hit "backspace" the change event trigger only if I click out the control. Here is what I have now. I will appreciate your help, Thank you in advance.

$('#dtpDOB, #dtpEffDate, #dtpRecDate').kendoDatePicker({
format: "MM/dd/yyyy",
change: paramChange
});

function paramChange()
{
var count = 0;
var dtpDOB = $("#dtpDOB").data("kendoDatePicker");
var dtpRecDate = $("#dtpRecDate").data("kendoDatePicker");
var dtpEffDate = $("#dtpEffDate").data("kendoDatePicker");
var button = $("#btnSearch").data("kendoButton");

if (dtpDOB.value() !== null)
count += 1;        
if (dtpRecDate.value() !== null)
count += 1;
if (dtpEffDate.value() !== null)
count += 1;

if(count >= 2)
button.enable(true);
else
button.enable(false);
}

2 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 10 May 2019, 11:16 AM
Hello Claudia,

The described behavior is expected as the change event of the input is triggered when the element is blurred and the value of the picker is updated within the change event handler of the input element.

The input event however is triggered when the value of the element has been changed. Therefore you could attach an input event handler and check for the values there:

$('#dtpDOB, #dtpEffDate, #dtpRecDate').kendoDatePicker({
format: "MM/dd/yyyy",
change: paramChange
}).on('input', function(e){
  var value = kendo.parseDate( $(e.target).val())
 
  ...
 
});

Please note that when the input event is triggered, the value of the picker is not yet updated and you will have to access it through the target as above.


Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Claudia
Top achievements
Rank 1
answered on 10 May 2019, 01:22 PM
Thank you so much!!! now is working ;)
Tags
Date/Time Pickers
Asked by
Claudia
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Claudia
Top achievements
Rank 1
Share this question
or