DatePicker

Hi! I am trying to figure out coding for the min.date option for the date picker. I want the minimum date to be 3 days from the current date. I tried a couple of different codes and none of them worked

Hi Samantha,

Here is a simple snippet code that you can use to set a min.date :

let date = new Date(); //current date
date.toLocaleString();
date.setDate(date.getDate()-3); // 3 days before
  $w("#datePicker").minDate = date; // assign the value to the datePicker

Hope this helps!
Best,

Mustafa

Thanks! I put in the code, but for some reason it is still letting me pick 10/10 as an option on the calendar (which is today). Do I have something wrong?

so you want it to be 3 days after the current date ?
all you have to do, is to change -3 to +3

you are amazing! and I appreciate the help sooo much! Thank you again

2 Likes

This code can only be added on specific pages such as the cart page and all pages you can drag and drop the date picker, but the checkout page is different, and Wix doesn’t yet support adding the date picker on the checkout page as of the moment. The Date Picker should be also encoded when a customer try to submit an order including their personal details like, Fullname, Contact number, address, billing info, etc.