V4 Date range picker not setting default value

I’m trying to initialize a date range picker with a default value of the current day. Not working.

$(this).mobiscroll().range({
   headerText: 'Select two dates',
   display:'bottom',
   showSelector: false,
   defaultValue: null,
   dateFormat: js_dateformat,
   defaultValue: ['2021-11-12','2021-11-12'],
   returnFormat: 'iso8601',
   buttons:['cancel','set'],
   min: mindate,
   max: maxdate,
   responsive: {
       small:{
         display: 'center'
       }
   },
   onSet: (ev, inst) => {
       var values = inst.getVal();
       var start = values[0];
       var end = values[1];

       $('#' + frominput).val(start);
       $('#' + toinput).val(end);
  }
});

Notice I’m setting the defaultvalue property like so

defaultValue: ['2021-11-12','2021-11-12']

According to the documentation (https://docs.mobiscroll.com/4-10-9/jquery/range#opt-defaultValue) this should work, but clearly I’m doing something wrong. Why is it not setting the default value for me?

Hello @Vincent_Wansink :wave:

Based on your code, you set the defaultValue twice and that’t the problem :point_down:

If null is passed, in case of the calendar control there will be no selected value.

Then you pass defaultValue: ['2021-11-12','2021-11-12'] - if you remove the first defaultValue, the second will set the initial date to 2021.11.12.

Also, you mentioned that you want to set default value of the current day, that’s the default behavior. If defaultValue is not provided, the default selection will be the current date and/or time.

Thank you! I didn’t even see that.