Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set maxDate on jquery ui datepicker to certain date

I want to set the maxDate of jQuery UI to 18/02/2013 but upon trying, it only lets me update it to today's date.

How can I go about doing this?

$("#datepicker'.$row['id'].'").datepicker({
    minDate: -0, 
    dateFormat: \'dd/mm/yy\',
    maxDate: 18/02/2013
});
like image 716
methuselah Avatar asked Feb 04 '13 11:02

methuselah


People also ask

How can change date format in jQuery UI Datepicker?

inside the jQuery script code just paste the code. $( ". selector" ). datepicker({ dateFormat: 'yy-mm-dd' });

How do I change the default date in Datepicker?

Syntax: $(". selector"). datepicker( {defaultDate:"+6"} );

How do I highlight a specific date in Datepicker?

datepicker({ beforeShowDay: function( date ) { var highlight = eventDates[date]; if( highlight ) { return [true, "event", 'Tooltip text']; } else { return [true, '', '']; } } }); The complete JavaScript code to highlight specific dates.

What is MinDate and MaxDate in jQuery Datepicker?

If you like to restrict access of users to select a date within a range then there is minDate and maxDate options are available in jQuery UI. Using this you can set the date range of the Datepicker. After defining these options the other days will be disabled which are not in a defined range.


1 Answers

Try this:

$("#datepicker").datepicker({ minDate: -0, maxDate: new Date(2013, 1, 18) });

If you want use hard coded date, use the new Date(2013, 1, 18) pattern.

If you want to use generic pattern, use "+1D +1M +1Y".

Reference link: http://jsfiddle.net/pradkumar_n/wQe8c/

like image 156
NPKR Avatar answered Oct 06 '22 03:10

NPKR