123
Views
4
Comments
[Datepicker] showing only the previous day
Question
Datepicker
Web icon
Forge asset by Hugo Pinheiro

How to disable the current day is to leave showing only the previous day?

2018-09-27 18-20-33
Swatantra Kumar
Champion

Do you want to show the previous day or also wants to disable current date in datepicker?

2025-10-29 14-26-01
Daianne Souza
Champion

Swatantra Kumar wrote:

Do you want to show the previous day or also wants to disable current date in datepicker?


I want to take the date today.

2018-09-27 18-20-33
Swatantra Kumar
Champion

Daianne Caetano Figueredo Souza wrote:

Swatantra Kumar wrote:

Do you want to show the previous day or also wants to disable current date in datepicker?


I want to take the date today.

In this case, just instantiate the class without any defaultDate value (default is null, which means today)

$( ".selector" ).datepicker();


2018-09-27 18-20-33
Swatantra Kumar
Champion

As, it's based on the https://jqueryui.com/datepicker, there are various options

For making previous date as default date https://api.jqueryui.com/datepicker/#option-defaultDate

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

To disable current date, you may set maxDate to previous date https://api.jqueryui.com/datepicker/#option-maxDate

$( ".selector" ).datepicker({  maxDate: "-1d"});



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.