# \[SOLVED\] Forms: Date & Time Picker

**URL:** <https://forum.wixstudio.com/t/solved-forms-date-time-picker/17499>\
**Category:** Ask the community\
**Tags:** wix-forms, code, question\
**Created:** [July 5, 2019, 3:54pm UTC](https://forum.wixstudio.com/t/solved-forms-date-time-picker/17499 "2019-07-05T15:54:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmormina](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/bmormina/32/82445_2.png) [@bmormina](https://forum.wixstudio.com/u/bmormina)\
**Post date:** [July 5, 2019, 3:54pm UTC](https://forum.wixstudio.com/t/solved-forms-date-time-picker/17499/1 "2019-07-05T15:54:46Z")

</div>

Hello,

1. Date picker: Is it possible to limit the date picker so a user _cannot_ choose today’s date and can only choose a future date. _i.e. Today is July 5th, but a user can only book July 6th onward._
2. Time picker: Is it possible to limit the selectable time to **working hours** (8am-6pm)

Thank you

---

<div class="post-metadata">

**Author:** ![Shan](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/shan/32/106059_2.png) [@Shan](https://forum.wixstudio.com/u/Shan)\
**Post date:** [July 5, 2019, 4:26pm UTC](https://forum.wixstudio.com/t/solved-forms-date-time-picker/17499/2 "2019-07-05T16:26:05Z")

</div>

For date picker set ‘Show text on load’ to ‘Placeholder text’ or ‘Nothing’

Then run this function under your onReady function:

```javascript
$w.onReady(function () {
  var today = new Date();
  var dd = today.getDate();
  var mm = today.getMonth();
  var yyyy = today.getFullYear();
  let badDate1 = new Date(yyyy, mm, dd);
  $w("#datePicker1").disabledDates = [badDate1];
});

```

I’m not sure about TimePicker but I would just use a Dropdown and set the options to be between 8am to 6pm.

---

<div class="post-metadata">

**Author:** ![bmormina](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/bmormina/32/82445_2.png) [@bmormina](https://forum.wixstudio.com/u/bmormina)\
**Post date:** [July 5, 2019, 4:55pm UTC](https://forum.wixstudio.com/t/solved-forms-date-time-picker/17499/3 "2019-07-05T16:55:18Z")

</div>

Thank you for your quick reply!  
This does disable “today’s date” which is awesome!  
However, I also need to block off weekends (Saturday and Sunday). This code seems to conflict with that. In the second image you will see _Sunday_ is still selectable and it should not be.  
Any ideas?

Thank you for your help!

 ![](https://us1.discourse-cdn.com/wix/original/3X/8/0/80449792f5b848b95bacece7bb6af2ebd183b970.png)

![](https://us1.discourse-cdn.com/wix/original/3X/f/3/f3212d443eb6e05655201d4ae9dc41cc990e0d9e.png)

---

<div class="post-metadata">

**Author:** ![Shan](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/shan/32/106059_2.png) [@Shan](https://forum.wixstudio.com/u/Shan)\
**Post date:** [July 5, 2019, 4:59pm UTC](https://forum.wixstudio.com/t/solved-forms-date-time-picker/17499/4 "2019-07-05T16:59:25Z")

</div>

Don’t insert an onReady function inside an onReady function.

This should only appear **once** on the page

```javascript
$w.onReady(function () {

```

---

<div class="post-metadata">

**Author:** ![bmormina](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/bmormina/32/82445_2.png) [@bmormina](https://forum.wixstudio.com/u/bmormina)\
**Post date:** [July 5, 2019, 5:04pm UTC](https://forum.wixstudio.com/t/solved-forms-date-time-picker/17499/5 "2019-07-05T17:04:31Z")

</div>

Thank you, will keep that in mind.

However, even with that removed Sunday is still selectable.

I have tried adding the following to block off Sunday, but the result is the same:  
$w(“#datePicker1”).disabledDaysOfWeek = [5,6];

Any ideas?

Once again, thank you for your help!

 ![](https://us1.discourse-cdn.com/wix/original/3X/9/c/9c0e65298a0befd73eb9cf8e3fa57f16cc61b7bf.png)

![](https://us1.discourse-cdn.com/wix/original/3X/c/9/c9f264db15fd5443e18ffcefe5b7996404ca5a21.png)

---

<div class="post-metadata">

**Author:** ![Shan](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/shan/32/106059_2.png) [@Shan](https://forum.wixstudio.com/u/Shan)\
**Post date:** [July 5, 2019, 5:05pm UTC](https://forum.wixstudio.com/t/solved-forms-date-time-picker/17499/6 "2019-07-05T17:05:30Z")

</div>

[5, 6] means Friday and Saturday

---

<div class="post-metadata">

**Author:** ![bmormina](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/bmormina/32/82445_2.png) [@bmormina](https://forum.wixstudio.com/u/bmormina)\
**Post date:** [July 5, 2019, 6:15pm UTC](https://forum.wixstudio.com/t/solved-forms-date-time-picker/17499/7 "2019-07-05T18:15:26Z")

</div>

Oops - you’re right!

Thank you for your help, Shan!

---

<div class="post-metadata">

**Author:** ![givemeawhisky](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/givemeawhisky/32/5383_2.png) [@givemeawhisky](https://forum.wixstudio.com/u/givemeawhisky)\
**Post date:** [July 5, 2019, 6:20pm UTC](https://forum.wixstudio.com/t/solved-forms-date-time-picker/17499/8 "2019-07-05T18:20:48Z")

</div>

Use the code that Shan has supplied for you and simply adjust the disabled days of the week to be set correctly as he stated, you just need to change your code and it is shown correctly in Wix API reference.  
[https://www.wix.com/corvid/reference/$w.DatePicker.html#disabledDaysOfWeek](https://www.wix.com/corvid/reference/$w.DatePicker.html#disabledDaysOfWeek)

#### Set Sundays and Saturdays to be disabled

```javascript
$w("#myDatePicker").disabledDaysOfWeek = [0, 6];

```

The disabledDaysOfWeek property accepts an array of integers from 0 to 6, where 0 represent Sunday, 1 is Monday, 2 is Tuesday, and so on.

Also, try your code first without using the set active days option in the datepicker itself to see if the code will does it all for you.
