Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to constrain users to select dates beyond today's date

I am using Vue3 with options API.

Given this StackBlitz, I would like to know how I can set :max value to a date-picker. I set the :max to new Date(), but I can still select dates beyond today’s date.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In template use :max="maxDate" then in your script do the following –

data() {
    return {
      maxDate: new Date().toISOString().split('T')[0], // Set the max date to today
    };
  },

I have fixed it at https://stackblitz.com/edit/vue-um9bae?file=src%2Fcomponents%2FHelloWorld.vue,src%2FApp.vue

Note the screenshot below shows future dates as disabled

image shows the fixed behaviour in date picker

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading