Show date outside certain limits MaxDate MinDate

I searched googled and tried to find out, but could not find a solution to this problem. When loading the page, I limit the datePickerfollowing values ​​to min and max:

$("#<%=txtboxDate.ClientID%>").datepicker({ 
minDate: new Date(2017, 2, 21),
 maxDate: new Date(2023, 07, 11) });

But I also have data before 2017-2-21<- (date format is yyyy-mm-dd) For example, it datePickeraccepts this format mm/dd/yy. Thus, the date he receives is “2/1/2017”. This is an exception to minDate.

How can I show these dates or only this date 2/1/2017in a calendar calendar datePickerwith the same specific restrictions on jquery?

+4
source share
3 answers

try it

<input id="dp" />

var d = $.datepicker.parseDate("mm/dd/yy", "12/21/2017");
$('#dp').datepicker({

    beforeShowDay: function (date) {
        return [date >= d, ''];
    }
});
$('#dp').datepicker("setDate", "12/10/2017");
+1
source

. , , .

, min ,

0

Set the date in the input field before initializing the date selection ( fiddle ). I believe this will solve your goal.

HTML:

Date Picker on input field: <input type="text" id="date1" name="date1"/> <br/>

JQuery

$(document).ready(function() {

  $('#thedate').datepicker({
    dateFormat: 'mm/dd/yy',
    minDate: new Date(2017, 12, 21),
    maxDate: new Date(2017, 12, 28)
  });

});
0
source

Source: https://habr.com/ru/post/1689688/


All Articles