Daniels Jirgensons Daniels Jirgensons - 15 days ago 4
Javascript Question

After select Bootrstrap datepicker date load to input field

I want to make, after select date on Bootstrap Datepicker, it's load a value on my input field, but I dont know how to do that. There's my JSFiddle.

This is my JQuery for datepicker

$(function () {
$('.datetimepickerinline').datetimepicker({inline: true});
});


I need to use it for all inputs, or in other words, closest input field.

Answer

Here is solution you want: jsfiddle

$('.datetimepickerinline').on('change dp.change', function(e){
    $('input').val($(this).data('date'));
});

See reference here

Further more, I noticed that you want use moment.js

You can use something like this, using custom format:

$('.datetimepickerinline').on('change dp.change', function(e){
   $('input').val(moment($(this).data('date')).format('DD/MM/YYYY, h:mm'));
});