Flatpickr: Empty field if minDate > value

Created on 15 Jul 2017  路  3Comments  路  Source: flatpickr/flatpickr

The same bug with maxDate <= value

Reproduction Link

https://jsfiddle.net/6kzs5ucm/

Your Environment

  • flatpickr version used: v3.0.6
  • Browser name and version: Yandex Browser 17.6.1.749
  • OS and version: Windows 10

Most helpful comment

I have an issue when I use minDate (ex. today) and my defaultDate is set two days earlier (user set it two days ago and now is editing the form). My input field is empty than.

Is there any workaround for this?

All 3 comments

Hello,

const fp = flatpickr(".date-min", {
    minDate: '2017-07-13'
 });
fp.setDate(new Date('2017-07-12'))

This is intentional.
There's no point of minDate if the user can select dates past it.
If you need to override minDate, then clear it before using setDate().

Also, regarding

const fp2 = flatpickr(".date-max", {maxDate: '2017-07-20'});
fp2.setDate(new Date('2017-07-20'))

Note that flatpickr regards '2017-07-20' as '2017-07-20 00:00'.
Meanwhile,

new Date('2017-07-20')
// Wed Jul 19 2017 20:00:00 GMT-0400 (EDT)

...which is less than the date specified above.

@chmln I create PR and remove this limitation. User don't can select value less than minDate. And we can select value less than minDate from code with setDate. I think it's good. I know a problem with my PR, and i can fix it if this idea will like to you.

I have an issue when I use minDate (ex. today) and my defaultDate is set two days earlier (user set it two days ago and now is editing the form). My input field is empty than.

Is there any workaround for this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GlennMatthys picture GlennMatthys  路  3Comments

mchaves-ciandt picture mchaves-ciandt  路  3Comments

deangibson89 picture deangibson89  路  3Comments

mgohin picture mgohin  路  4Comments

titiyoyo picture titiyoyo  路  3Comments