I’m having this problem with the code and I think you can help me or direct me to the technical support.
When loading the calendar, the invalid dates appear inactive. Just as expected. However, on the first click of the initial date, the invalid dates are activated and after that they do not become inactive again. I’m looking for a way to keep them inactive all the time. Is it possible to do that?
Sumary: I want to keep invalid dates always deactived.
// Mobiscroll
$(‘#date_from_to’).mobiscroll().range({
startInput: ‘#start’,
endInput: ‘#end’,
min: min_date,
fromText: ‘Receber em’,
toText: ‘Devolver em’,
minRange: 8 * day,
//showSelector: false,
yearChange: false,
invalid: [
‘1/1/23’, // 1st of January disabled
‘20/2/23’, //Carnaval
‘21/2/23’, //Carnaval
‘7/4/23’, //Holliday
‘21/4/23’, //Holliday
‘1/5/23’,
‘8/6/23’,
‘7/9/23’,
‘12/10/23’,
‘2/11/23’,
‘15/11/22’,
‘25/12/22’, // Christmas disabled
‘w0’, // disable sundays
],
labels: [
{d: ‘1/1/23’,text: ‘Holliday’,color: ‘red’},
{d: ‘20/2/23’, text: ‘Holliday’, color: ‘red’ },
{d: ‘21/2/23’, text: ‘Holliday’, color: ‘red’ },
{d: ‘7/4/23’, text: ‘Holliday’, color: ‘red’ },
{d: ‘21/4/23’, text: ‘Holliday’, color: ‘red’ },
{d: ‘1/5/23’, text: ‘Holliday’, color: ‘red’ },
{d: ‘8/6/23’, text: ‘Holliday’, color: ‘red’ },
{d: ‘7/9/23’, text: ‘Holliday’, color: ‘red’ },
{d: ‘12/10/23’, text: ‘Holliday’, color: ‘red’ },
{d: ‘2/11/23’,text: ‘Holliday’,color: ‘red’},
{d: ‘15/11/23’,text: ‘Holliday’,color: ‘red’},
{d: ‘25/12/23’, text: ‘Holliday’, color: ‘red’ },
],onSet: function (event, inst) { $('[name=date_from], [name=date_to]').each(function(index){ $(this).val(moment($('#date_from_to').mobiscroll('getVal')[index]).format('YYYY-MM-DD')); }); }, onSetDate: function (ev, inst) { var i, start, minDays = 8, invalid = inst.settings.invalid; if (ev.control == 'calendar') { invalid.length = 0; // Add constant invalids for (i = 0; i < invalid.length; i++) { invalid.push(invalid[i]); } if (ev.active == 'start') { start = inst.getVal(true)[0]; // Add next 4 days to invalids for (i = 1; i < minDays - 1; i++) { invalid.push(new Date(start.getFullYear(), start.getMonth(), start.getDate() + i)); } } // Redraw the calendar inst.redraw(); } }
});