cicakman
cicakman

Reputation: 1990

Disable future dates in jQuery UI Datepicker

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.

Upvotes: 77

Views: 121890

Answers (9)

pankaj jain
pankaj jain

Reputation: 141

Try This:

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

It will disable the future date.

Upvotes: 14

Praddyumna Sangvikar
Praddyumna Sangvikar

Reputation: 149

you can use the following.

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

Upvotes: 4

user6230444
user6230444

Reputation: 1

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

Upvotes: -2

Gaurav Malik
Gaurav Malik

Reputation: 45

Yes, datepicker supports max date property.

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

Upvotes: 0

Bharathi
Bharathi

Reputation: 1

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',
});

Upvotes: 0

Cyril Gupta
Cyril Gupta

Reputation: 13723

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) });

Upvotes: 128

Abdul Rehman
Abdul Rehman

Reputation: 689

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

Upvotes: 3

JAY
JAY

Reputation: 49

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',''); 

Upvotes: 3

ArK
ArK

Reputation: 21068

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

Upvotes: 38

Related Questions