Disable future dates in jQuery UI Datepicker

JqueryDateJquery Ui-DatepickerFutureDisable Link

Jquery Problem Overview


Is it possible to disable future date from today?

Let say today is 23/10/2010, so 24/10/2010 onwards are disabled.

Sorry I am very new in jQuery and JavaScript.

Jquery Solutions


Solution 1 - Jquery

Yes, indeed. The datepicker has the maxdate property that you can set when you initialize it.

Here's the codez

$("#datepicker").datepicker({ maxDate: new Date, minDate: new Date(2007, 6, 12) });

Solution 2 - Jquery

$(function() { $("#datepicker").datepicker({  maxDate: '0'}); });

Solution 3 - Jquery

Try This:

$('#datepicker').datepicker({
    endDate: new Date()
});

It will disable the future date.

Solution 4 - Jquery

Code for Future Date only with disable today's date.

 var d = new Date();
         $("#delivdate").datepicker({
		 showOn: "button",
		 buttonImage: base_url+"images/cal.png",
		 minDate:new Date(d.setDate(d.getDate() + 1)),
		 buttonImageOnly: true
        });
		 $('.ui-datepicker-trigger').attr('title',''); 

Solution 5 - Jquery

Date for the future 1 year can be done by

$('.date').datepicker({dateFormat: 'yy-mm-dd', minDate:(0), maxDate:(365)});

you can change the date format too by the parameter dateFormat

Solution 6 - Jquery

you can use the following.

$("#selector").datepicker({
    maxDate: 0
});

Solution 7 - Jquery

http://stefangabos.ro/jquery/zebra-datepicker

use zebra date pickers:

$('#select_month1').Zebra_DatePicker({
  direction: false,
  format: 'Y-m-d',
  pair: $('#select_month2')
});

$('#select_month2').Zebra_DatePicker({
  direction: 1, format: 'Y-m-d',
});

Solution 8 - Jquery

Yes, datepicker supports max date property.

 $("#datepickeraddcustomer").datepicker({  
			 dateFormat: "yy-mm-dd",  
			 maxDate: new Date()  
		});

Solution 9 - Jquery

$('#thedate,#dateid').datepicker({
	 changeMonth:true,
         changeYear:true,
         yearRange:"-100:+0",
         dateFormat:"dd/mm/yy" ,
		 maxDate: '0',
	 });
});

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioncicakmanView Question on Stackoverflow
Solution 1 - JqueryCyril GuptaView Answer on Stackoverflow
Solution 2 - JqueryArKView Answer on Stackoverflow
Solution 3 - Jquerypankaj jainView Answer on Stackoverflow
Solution 4 - JqueryJAYView Answer on Stackoverflow
Solution 5 - JqueryAbdul RehmanView Answer on Stackoverflow
Solution 6 - JqueryPraddyumna SangvikarView Answer on Stackoverflow
Solution 7 - JqueryBharathi View Answer on Stackoverflow
Solution 8 - JqueryGaurav MalikView Answer on Stackoverflow
Solution 9 - Jqueryuser6230444View Answer on Stackoverflow