javascript - Jquery datepicker change event trigger and input's default change event -
i have datepicker
<input type='text' class='inp'> <script> $('.inp').datepicker(); $(".inp").on("change",function (){ console.log('inp changed'); }); </script>
when first change '.inp' manually type there value, click on datepicker's opened calendar. 2 'change' event listeners. first manual change, datepicker change. how can avoid this? thanks!
set input readonly
, change value of field through icon only.
<input type='text' class='inp' readonly />
then use onselect
selected date, following:
$(function() { $(".inp").datepicker({ onselect: function(datetext, inst) { // alert(datetext); } }); });
Comments
Post a Comment