amsul / pickadate.js

The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
http://amsul.ca/pickadate.js
MIT License
7.7k stars 1.02k forks source link

How to disable time after choose date in datetimepicker #1174

Closed rizki5411 closed 5 years ago

rizki5411 commented 5 years ago

I have two form, form date and form time.

$("#tanggal1").pickadate({
                min: true
            })

            $("#jam1").pickatime({
                min: [7,0],
                max: [15,0],
                interval: 60,
                disable: [
                    new Date(2019,7,2,13,0)
                ]
            }) 

How is it done so that when the user selects a date then the time will be disabled according to the date chosen. Thanks guys.

DanielRuf commented 5 years ago

Hi @rizki5411,

You can use the API for this.

https://amsul.ca/pickadate.js/api/ https://amsul.ca/pickadate.js/api/#method-set-disable-enable

Some example code:

// get the timepicker instance

var $input = $('.datepicker').pickatime()

// Use the picker object directly.
var picker = $input.pickadate('picker')
picker.set('disable', [

  // Using a collection of arrays formatted as [YEAR,MONTH,DATE]
  [2016,9,3], [2016,9,9], [2016,9,20],

  // Using JavaScript Date objects
  new Date(2015,9,13), new Date(2015,9,24)
])
rizki5411 commented 5 years ago

i see this example use pickadate, how to i use with pickatime?

DanielRuf commented 5 years ago

Try it with .pickatime().

For most examples on this page, the date picker is used, but the same API applies to the time picker as well.

rizki5411 commented 5 years ago

I'm trying to make a scheduling application. When the user enters a date (.pickadate) then from there the user enters the clock (.pickatime), now here he will check what time is busy from that date to then be disabled. How to do this mr?

DanielRuf commented 5 years ago

There are events and methods for hooking into the change and submit events (we provide a set event / callback).

rizki5411 commented 5 years ago

Thank's mr, my problem has been clear

DanielRuf commented 5 years ago

For completeness the events: https://amsul.ca/pickadate.js/api/#events-callbacks