Datepicker Year Dropdown Default Value

I have a date picker field

<input id="text1" name="text1" type="text" class="form-control" 
is="dmx-date-picker" format="YYYY-MM-DD" showdropdowns="true" 
maxyear="2009" minyear="1944">

And it all works fine. The dropdowns display the years between the min and max years no problem.

The problem is that the dropdown for years defaults to 1944 and most of my users will be selecting dates likely in the 1990’s. I’d like the iniital value in the dropmenu for the year to be around 1994 so users don’t have to scroll so much when selecting the year. Is this possible?

Unfortunately that’s not possible. We’re using the daterangepicker for this component and it will only default to the current year in the dropdown if it’s in the allowed range.

1 Like

Thanks. That’s what I thought.

It seems you can do it like this and it seems to work


1 Like

Thanks. Yep, using a value works. I did think of that. But unfortunately it adds a value in the input. I have to keep in mind the laziness of the end user and if there is already a value in the input they will likely just skip over it. Hence I can’t mark it as required as it will be pre-filled with a wrong date.

This is easy to solve - add a hidden variable, assign it 0 and when the DataPicker changes event, assign the date the user selected to this variable. And if this variable is 0 - highlight the DataPicker, block sending or issue a warning - to your taste

Hmmm, interesting work around. Thank you. I will experiment.