Vuetify Disable Past Date in DatePicker

Vuetify Disable Past Date in DatePicker:In this tutorial, we will learn how to disable past dates in a DatePicker using Vuetify. We will provide a step-by-step example to help you understand and implement this feature in your own Vuetify project.

 

Profile Photo

Abhishek Yadav (SD) SDE of FAI

Feedback

written
Profile Photo

Anil Kumar (Expert) Coding Expert of FAI

Feeback

reviewed
Profile Photo
Oct 31, 2023 12:10 PM Last Updated
updated

Disabling Past Dates in Vuetify DatePicker

To disable past dates in a Vuetify DatePicker, we will utilize the :min property, which allows us to set the minimum selectable date. By setting the :min property to the current date, we can ensure that users cannot select any date prior to the current date. Here's the code to achieve this:

Vuetify Disable Past Date In DatePicker Example

Copied to Clipboard
Run

In the JavaScript section of our example:

Copied to Clipboard

Explanation:

  1. We begin by creating a Vuetify card that contains a DatePicker. The :min property is set to the minDate data property. This property will prevent users from selecting any date earlier than the current date.

  2. In the JavaScript section, we create a new Vue instance and initialize Vuetify. We set the date data property with an initial date value of '2023-09-16', which can be changed as per your requirements.

  3. The minDate data property is set to the current date using JavaScript's new Date() and toISOString() functions. It's formatted to match the DatePicker's date format

Output of Vuetify Disable Past Date In DatePicker 

When you run this code, you'll see a Vuetify DatePicker that prevents the selection of past dates. Users can only pick dates starting from the current date, ensuring data accuracy and usability in your application

Pasted Image

Ad