Home > Software design >  How to call an event when my Input's value changes with JavaScript Date Picker?
How to call an event when my Input's value changes with JavaScript Date Picker?

Time:11-22

There is an input which is Date Picker. It is impossible to type in the input, everybody can only pick a date by mouse. enter image description here

How can I call an event when the user changes Date ?

Here is HTML Code:

<div class="col-lg-3 col-md-3 col-xs-12">
    <label for="homeWorkStartDate">From: </label>
    <input type="text" id="homeWorkStartDate" class="pdate form-control" />
    <input type="hidden" id="txtHomeWorkStartDate" />
    <script>
        var objCal1 = new AMIB.persianCalendar('homeWorkStartDate', {
            extraInputID: 'txtHomeWorkStartDate',
            extraInputFormat: 'YYYY-MM-DD'
        });
    </script>
</div>
<div class="col-lg-3 col-md-3 col-xs-12">
    <label for="homeWorkEndDate">To: </label>
    <input type="text" id="homeWorkEndDate" class="pdate form-control" />
    <input type="hidden" id="txtHomeWorkEndDate" />
    <script>
        var objCal1 = new AMIB.persianCalendar('homeWorkEndDate', {
            extraInputID: 'txtHomeWorkEndDate',
            extraInputFormat: 'YYYY-MM-DD'
        });
    </script>
</div>

Here is what I tried but doesn't work:

$("#homeWorkStartDate,#homeWorkEndDate").on('input propertychange',function(){
    alert("hi");
});

CodePudding user response:

Did you try something like this ?

$( "#datepicker" ).datepicker({
    onSelect: function () {
        alert('hello');
    }
})
  • Related