jQuery UI Datepicker 2 dates in the same week

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:

  1. $(function() {
  2.     var dates = $("#holiday_from, #holiday_to").datepicker({
  3. prevText: '<zurück', prevStatus: '',
  4.         prevJumpText: '<<', prevJumpStatus: '',
  5.         nextText: 'Vor>', nextStatus: '',
  6.         nextJumpText: '>>', nextJumpStatus: '',
  7.         currentText: 'heute', currentStatus: '',
  8.         todayText: 'heute', todayStatus: '',
  9.         clearText: '-', clearStatus: '',
  10.         closeText: 'schließen', closeStatus: '',
  11.         monthNames: ['Januar','Februar','März','April','Mai','Juni',
  12.         'Juli','August','September','Oktober','November','Dezember'],
  13.         monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
  14.         'Jul','Aug','Sep','Okt','Nov','Dez'],
  15.         dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
  16.         dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
  17.         dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
  18.         dateFormat: 'yy-mm-dd',
  19. showMonthAfterYear: false,
  20. showOn: 'both',
  21.         minDate: new Date(2016, 2 - 1, 2),
  22. firstDay: 1,
  23.         onSelect: function(selectedDate) {
  24.             $("#target").load("website_to_load.html?value=" + document.getElementById("holiday_from").value);
  25.             var option = this.id == "holiday_from" ? "minDate" : "maxDate",
  26.             instance = $(this).data("datepicker"),
  27.             date = $.datepicker.parseDate(
  28.             instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
  29.             dates.not(this).datepicker("option", option, date);
  30.         }
  31.     });
  32. });
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)