qodesmith / datepicker

Get a date with JavaScript! A datepicker with no dependencies.
344 stars 101 forks source link

Allow setMin() to adjust dateSelected when the current value is earlier than the new mininum #141

Open jontjs opened 1 year ago

jontjs commented 1 year ago

Currently if you have a picker with, for example, 2023-08-11 selected, then use setMin() to change the minimum date to 2023-08-16, an error is thrown "Out-of-range" error is thrown.

It would be useful if there was an option for setMin() to adjust the selected date to the new minimum.

I can appreciate that this may not be a desirable default, so perhaps an optional (bool)adjustSelectedIfOutOfRange argument would be better. Or a separate method altogether.

I suppose the same reasoning applies to setMax(), though I personally haven't encountered that.