jQuery UI Datepicker 2 dates in the same week
Hey Guys,
i hope u can help me...
i need two date inputs with datepicker and the second must be after the first date choosen... thats no problem with my code...
but i've need a second rule:
after first choose the second date must be max the sunday in the same week than the first date.
thats my code now for the first rule:
- $(function() {
- var dates = $("#holiday_from, #holiday_to").datepicker({
- prevText: '<zurück', prevStatus: '',
- prevJumpText: '<<', prevJumpStatus: '',
- nextText: 'Vor>', nextStatus: '',
- nextJumpText: '>>', nextJumpStatus: '',
- currentText: 'heute', currentStatus: '',
- todayText: 'heute', todayStatus: '',
- clearText: '-', clearStatus: '',
- closeText: 'schließen', closeStatus: '',
- monthNames: ['Januar','Februar','März','April','Mai','Juni',
- 'Juli','August','September','Oktober','November','Dezember'],
- monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
- 'Jul','Aug','Sep','Okt','Nov','Dez'],
- dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
- dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
- dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
- dateFormat: 'yy-mm-dd',
- showMonthAfterYear: false,
- showOn: 'both',
- minDate: new Date(2016, 2 - 1, 2),
- firstDay: 1,
- onSelect: function(selectedDate) {
- $("#target").load("website_to_load.html?value=" + document.getElementById("holiday_from").value);
- var option = this.id == "holiday_from" ? "minDate" : "maxDate",
- instance = $(this).data("datepicker"),
- date = $.datepicker.parseDate(
- instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
- dates.not(this).datepicker("option", option, date);
- }
- });
- });
I've tried a lot with maxDate for the second input put i didn't get it :(
i'm not so good in js so i hope u can help me with...
(sorry for my bad english - i hope u can understand me)