Doctor06
Doctor06

Reputation: 697

How to know if date has change in datepicker jQuery

I have a date picker tied in with a calendar icon. when you click it and select a date, it populates a readonly text field. What i'm trying to do is i want to know when and if the date has changed.

I tried:

$(document).ready(function () {
  $("#individual_due_date_1").change(function(){
    alert("hello");
  });
}

but the code never gets ran. is there another way of doing this? or am i doing this wrong? any help would be appreciated.

Upvotes: 1

Views: 1940

Answers (1)

adeneo
adeneo

Reputation: 318182

The change event is not fired when the value changes dynamically, but the datepicker has an onSelect event you should be using.

$(document).ready(function () {
    $(".datepicker").datepicker({
        onSelect: function() {
            // datepicker changed
        }
    });
});

Upvotes: 1

Related Questions