Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap Datepicker won't update input value

I have this code, but now i am stuck:

<input type="text" id="datepicker" value="/">

<script type="text/javascript">
    $('#datepicker').datepicker()
        .on('changeDate', function(ev){
            // Some code..
        });
</script>

I want the value of input field to update every time the new date is selected. I want the value to be the date, that was selected.

like image 612
intelis Avatar asked Nov 27 '12 19:11

intelis


1 Answers

$(document).ready(function(){

    var dp = $("#datepicker");

    dp.datepicker({
        format : 'mm-dd-yyyy',
    });

     dp.on('changeDate', function(ev){
       dp.val(ev.target.value);
    });

});
like image 73
intelis Avatar answered Oct 27 '22 10:10

intelis