I'm using the datePicker in the jQuery UI core. I need a date picker that can only pick dates through the past all the way to today.
Is there an easy way to do this? -- Note I'm using the UI core, not the DatePicker Plugin.
My jQuery call:
$(function() {
$(".datepicker").datepicker();
});
Set Current Date in DatePicker using jQueryvar now = new Date(); var day = ("0" + now. getDate()).
inside the jQuery script code just paste the code. $( ". selector" ). datepicker({ dateFormat: 'yy-mm-dd' });
How do I turn off past date in calendar? the previous dates we need to set the minDate property of the date picker. if we set minDate:0 then it will disable all the previous dates. and we set input attribute min:current_date then it will disable all the previous dates.
The datepicker is tied to a standard form input field. Focus on the input (click, or use the tab key) to open an interactive calendar in a small overlay. Choose a date, click elsewhere on the page (blur the input), or hit the Esc key to close. If a date is chosen, feedback is shown as the input's value.
You should use the maxDate option when initializing the datepicker:
$( ".datepicker" ).datepicker({ maxDate: '0' });
look here for reference: http://jqueryui.com/demos/datepicker/#option-maxDate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With