Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
Bootstrap Datepicker get user selected date when it is from saved date (via setDates)

$(function(){

    $( ".cal_date" ).datepicker({
        format: 'yyyy-mm-dd',
        todayHighlight:true,
        viewDate:true,
        multidate: true,

    })
    .on('changeDate', function(e) {
            console.log(e.format());
        }
    )
    $( "#datepicker_12492" ).datepicker('setDates',["2022-03-12","2022-03-15","2022-03-18","2022-03-13","2022-03-31"]);

});
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.standalone.min.css" rel="stylesheet">




<div class="cal_date" id="datepicker_12492"></div>

I have multiple bootstrap datepickers on a page and each one will select multiple dates and save them to database. This works using onchangedata and e.format(). The problem is when the calendar is loaded with the saved dates and you try to unselect a saved one when there are multiple dates. e.format() doesn't return the selected date. In the example, if you select 2022-03-15, it will show 2022-03-31 in the changeDate function.

$( ".cal_date" ).datepicker({
                format: 'yyyy-mm-dd',
                todayHighlight:true,
                viewDate:true,
                multidate: true,

            })
            .on('changeDate', function(e) {
                console.log(e.format());
    });
     $( "#datepicker_userid" ).datepicker('setDates',["2022-03-12","2022-03-15","2022-03-18","2022-03-13","2022-03-31"]);

I am sure it is something easy I am missing, but any help is appreciated.

Thanks!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!