Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Disable old dates in datepicker

akademe pro asked 6 years ago


Hi Team,

I would like to disable all older dates, user should be able to pick current date to upcoming dates, older dates should be disabled, checked mdb options but we have to give range for disabling, how to disable older dates? making a calendar to select present date to future date, rest date starting from yesterday should be disabled.

Regards,
Akademe


Damian Gemza staff answered 6 years ago


Dear akademe,

Your desired behavior is very easy to achieve. Just use disableUntil option, and that's all.

Please check the below code - it will disable all dates until 2018-11-15

disableUntil: { year: 2018, month: 11, day: 15 }

This code will disable all dates until today - generated from JavaScript Date object:

disableUntil: { year: this.date.getFullYear(), month: this.date.getMonth() + 1, day: this.date.getDate() }

Best Regards,

Damian



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 6.2.3
  • Device: mac air
  • Browser: chrome
  • OS: machintosh
  • Provided sample code: No
  • Provided link: No
Tags