Delimit certain dates in a range with input type = date, datepicker or similar

1

I am working with ranges of dates, for a holiday period, in the end it turns out that I never take into account Saturdays, Sundays or holidays.

example.

01-02-2017 & 09-02-2017 which is equal to 8 days of holidays in this case, but 4 and 5 of February falls on Saturday and Sunday then on that range discount two days that would give an equal to 6 days hablies plus 10 and 13 of February Friday and Monday respectively to comply with 8 days equivalent to the days before mentioned.

The question is whether in datepicker I can generate an arrangement with certain dates on weekends or holidays. my date difference script is as follows.

$('#f1').on('change',function(){
$('#dias').val('');
var f1= new Date($('#f1').val());
var f2= new Date($('#f2').val());
var fechaResta = f2- f1;
var dias = ((((fechaResta / 1000) / 60) / 60) / 24);
$('#dias').val(!isNaN(dias) ? dias : ''); 

Maybe someone knows a script that can help me with this problem

    
asked by matteo 21.02.2017 в 19:20
source

1 answer

1

Able this serves you

beforeShowDay: function (day) { 
       var day = day.getDay(); 
       if (day == 5 || day == 6) { 
         return [false, "somecssclass"] 
       } else { 
         return [true, "someothercssclass"] 
       } 
     } 

The beforeShowDay is a function of the datepicker of jquery UI and in the if you only change the numbers for the days you need to be disabled (Sunday: 0, Monday: 1, Tuesday: 2, Wednesday: 3 ... etc )

    
answered by 21.02.2017 в 19:25