user2527785
user2527785

Reputation: 117

Timepicker Restriction Current Time

Hi I have used datePicker and set minDate to 0 to restrict access to past dates.

Now I am trying to use timepicker and restrict access to previous times being selected, it is as easy as just passing in one value like for datePicker, or do I need to do more.

I am not great at writing javascript so if someone could show me a solution if its complicated, do I need to get current hour and current min first and how do i then restrict the timepicker to just show times after this?

Upvotes: 1

Views: 1200

Answers (1)

Suresh Atta
Suresh Atta

Reputation: 122026

Something like this ??

$('#timepicker').timepicker({
    onHourShow: function( hour ) { 
        var currenttime = new Date();
        if ( $('#datepicker').val() == $.datepicker.
                                  formatDate ( 'mm/dd/yy', currenttime ) ) {
            if ( hour <= currenttime.getHours() ) {
                alert('nope');
                return false;
            }
        }
        return true;
    }
});

Upvotes: 1

Related Questions