Skip to content

Jquery datepicker change event trigger and input’s default change event

I have datepicker

  <input type='text' class='inp'>  

  $(".inp").on("change",function (){ 
   console.log('inp changed');

When I first change ‘.inp’ manually type there a value, then immediately I click on datepicker’s opened calendar. I get two ‘change’ event listeners. First from manual change, then from datepicker change. How can I avoid this?


Set your input readOnly, it will help you to change the value of field through icon only.

<input type='text' class='inp' readOnly />

then use onSelect to get selected date, as following:

$(function() {
        onSelect: function(dateText, inst) {
            // alert(dateText);