I want to disable next 30 days in datepicker. For ex. It is 27th March today so the user will be able to select anything after 27th April. This I have tried so far-
<!DOCTYPE html>
<html>
<body>
<div class="demo">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<p>Date: <input type="text" id="datepicker"></p>
<script>
var today = new Date();
var D = today.getDate();
var M = today.getMonth()+2;
var Y = today.getFullYear();
$( '#datepicker' ).datepicker({
format: "dd mm yyyy",
autoclose: true,
startDate: new Date(D,M,Y),
});
</script>
</body>
</html>
Unfortunately I am not able to achieve the desired result. However there is no error message in the console.
You can use this code.
$( function() {
$( "#datepicker" ).datepicker({ minDate: "+1M" });
} );
I have not tried this but according to their doc it should work.
+1M
will add exact one month not days.
Try with
minDate: "+30d",
before the autoclose
or
$('#datepicker')({
minDate: "+30d"
});
Also you can use "+1M" instead of "+30d" to add 1 entire month.
Try this one:
$('#datepicker').datepicker({
minDate: "+30d"
});
Explanation: minDate
is used to set the date from which datepicker starts.
/*there is problem in parsing the date you can use the following format
the calender will start from the next months date from new date
*/
var today = new Date();
var D = today.getDate()+1;
var M = today.getMonth()+1;
var Y = today.getFullYear();
var date = new Date(Y,M,D);
Here is one example for datepicker, to select 30days
$("#datepicker").datepicker({
format: "dd/mm/yyyy",
startDate: new Date(),
endDate: "+30d"
});
You can use this code:
var max = new Date('April 26, 2018');
$('#datepicker').datepicker('option', 'maxDate', max);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.