Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery-ui Datepicker return first day of selected week
    text
    copied!<p>How can I edit my datepicker to return the first day of the selected week? Currently, it always returns the exact date of the selected date.</p> <p>What I want is: If I select "Wednesday 28/08/2013" the datepicker should return "Monday 26/08/2013". How can I achieve this?</p> <p>if I write in textboxfor <code>@id="#startDate</code> don't work.</p> <pre><code>@Html.TextBoxFor(m =&gt; m.datS, new { @type = "text", @width = "80", @maxlength = 10, @readonly = "true" }) @Html.TextBoxFor(m =&gt; m.datE, new { @type = "text", @width = "80", @maxlength = 10, @readonly = "true" }) </code></pre> <p>Here is javascript for datepicker.</p> <pre><code> $(function () { var startDate; var endDate; var dateToday = new Date(); var selectCurrentWeek = function () { window.setTimeout(function () { $('#datS, #datE').find('.ui-datepicker-current-day a').addClass('ui-state-active') }, 1); } $('#datS, #datE').datepicker({ onSelect: function (dateText, inst) { var date = $(this).datepicker('getDate'); startDate = new Date(date.getFullYear(), date.getMonth(), date.getDate() - date.getDay() - 1); endDate = new Date(date.getFullYear(), date.getMonth(), date.getDate() - date.getDay() + 5); var dateFormat = inst.settings.dateFormat || $.datepicker._defaults.dateFormat; $('#startDate').text($.datepicker.formatDate(dateFormat, startDate, inst.settings)); $('#endDate').text($.datepicker.formatDate(dateFormat, endDate, inst.settings)); selectCurrentWeek(); }, onClose: function (selectedDate, test) { var day = ('0' + (parseInt(test.selectedDay))).slice(-2); var month = ('0' + (test.selectedMonth)).slice(-2); var year = test.selectedYear; var tempDate = new Date(year, month, day); if (this.id == "datS") { tempDate.setDate(tempDate.getDate() + 1); $("#datE").datepicker("option", "minDate", tempDate); } if (this.id == "datE") { tempDate.setDate(tempDate.getDate() - 1); $("#datS").datepicker("option", "maxDate", tempDate); } } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload