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

160
Views
How to add one and more leaves in jquery datepicker

I add leave in datepicker using array but, two leave is on same day is not showing in calendar only first leave in array is showing but second leave is not showing.

my var leaveday array is like this = "2021,09,28,Love is on Leave-2021,09,18,Pravin is on Leave-2021,09,25,Darshit is on Leave-2021,09,18,Love is on Leave-"

my jquery is here

var leave_dates= $("#all_past_leave").val();
if(leave_dates !== null && leave_dates !== '' && leave_dates !== undefined) {
    var leave_all = leave_dates.slice(0,-1);
    var leaveDays = leave_all.split('-');
 }
$(function() {
    $("#past_leave").datepicker({
        numberOfMonths:3,
       beforeShowDay: setLeaveDays
    });
  
    // set Leave function which is configured in beforeShowDay
   function setLeaveDays(date) {
     for (i = 0; i < leaveDays.length; i++) {
          
        var leaveData = leaveDays[i].split(',');

        if (date.getFullYear() == leaveData[0]
            && date.getMonth() == leaveData[1] - 1
            && date.getDate() == leaveData[2]) {
          return [true, 'staff_leaves', leaveData[3]];
       }
     }
    return [true, ''];
  }
  });

I am getting result like this see image here

but I want result like this I edited from chrome inspect for example see image here

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!