giorno jquery datepicker MinDate specifico in mese in corso
-
10-10-2019 - |
Domanda
H
Ho bisogno di personalizzare due datepickers.
Per prima shold ha:
- MinDate: ultimi giorni dieci di questo mese (o se più semplice: 20 di questo mese)
- MaxDate: 10 ° giorno del mese successivo
posso solo impostare poi come indicato in "manuale" in questo modo: + 1m + 2W + 5d. Ma questo non è buono nel mio caso, poiché non ho bisogno di andare relativa ai dati attuali.
Qualche idea?
Ho provato questo senza fortuna:
// temp vars used below
var currentTime = new Date()
// DATEPICKER CURENT MONTH - all fields with class: datepicker_current_month
$(".datepicker_current_month").datepicker({
dateFormat: 'dd.mm.yy',
// minDate: '+10d',
minDate: new Date(currentTime.getYear(), currentTime.getMonth(), 20),
maxDate: '+3w'
});
BR. Anders
UPDATE - Soluzione Ho usato la risposta da undertakeror e funziona bene. Thnaks per la risposta: -)
// temp vars used below
var currentTime = new Date();
var startDateFrom = new Date(currentTime.getFullYear(), currentTime.getMonth() +1, -10); // 10 days before next month
var startDateTo = new Date(currentTime.getFullYear(), currentTime.getMonth() +1, -1); // one day before next month
var endDateFrom = new Date(currentTime.getFullYear(), currentTime.getMonth() +1, 3); // 3rd of next month
var endDateTo = new Date(currentTime.getFullYear(), currentTime.getMonth() +1, 10); // 10th of next month
// DATEPICKER CURENT MONTH - all fields with class: datepicker_current_month
$(".datepicker_current_month").datepicker({
dateFormat: 'dd.mm.yy',
minDate: startDateFrom,
maxDate: startDateTo
});
Soluzione
This is a nice plugin and has a lot of configuration options http://plugins.jquery.com/project/datepicker . You can find the documentation here http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/documentation.html and some demos here http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/
that being said, i don't know if it is easier to use then the one you tried, but the idea is that you still have to compute the days yourself, something like http://jsfiddle.net/m2HPr/2/
Hope it helps