Reputation: 10526
Using Javascript, how can I attach an event listener for when the datetime has been changed in the Bootstrap DatetimePicker (Homepage)
<script>
$(function(){
document.getElementById('dtp1').addEventListener('change',function(e){
//Do Something
});
});
</script>
However the above function isn't getting fired when I change the date either by using keyboard or the mouse (point and click).
The HTML Looks like this:
<div class="form-group">
<div class='input-group date' id='dtp1'>
<span class="input-group-addon" id="basic-addon1">Date</span>
<input type='text' class="form-control"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
If someone would advise the correct way to do this, I would be most appreciative.
Upvotes: 0
Views: 2432
Reputation: 10526
I worked out a solution that achieves a result.
<script>
$("#dtp1").on("dp.change",function (e) {
//Do Something
});
</script>
Upvotes: 4