Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7834527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:14:13+00:00 2026-06-02T13:14:13+00:00

I am having two fields in my form. One is date field which is

  • 0

I am having two fields in my form. One is date field which is using jQuery date picker and another one is jQuery time picker. Now the problem is, if i select the today’s date in the date field, then the time picker should not shows the past time. For eg. if the time now is 17:00 hrs, then the timepicker should not shows the time before 17:00 hrs as selectable. Here is my code,

$(function() {
    $( ".datepicker" ).datepicker({minDate:'0'});
    $('.timepicker').timepicker();
});

$("#date").click(function(){
    if($("#date").val()=='04/17/2012')
    {
        updatetimefortoday();
    }
});![enter image description here][1]

function updatetimefortoday()
{
    $('.timepicker').timepicker({
        onHourShow: timepickerRestrictHours
    });

    function timepickerRestrictHours(hour)
    {
        if ((hour > 17))
        {
            return true;
        }
        return false;
    }
}

Now the problem is if we call the function updatetimefortoday() on document.ready, it is showing the timepicker correctly. But if we do it on click of the date field as shown in the code it is not working.

enter image description here

This is the expected output after selecting the date.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T13:14:14+00:00Added an answer on June 2, 2026 at 1:14 pm

    After working a bit more with it, I came to the conclusion that the best way to do that is to always call the onHourShow function and validate the selected date in that function. I think this is better because the disabled hours are still visible to the user instead of blank cells.

    $('#date').datepicker({
        minDate: 0
    });
    $('#time').timepicker({
        onHourShow: function( hour ) { 
            var now = new Date();
            // compare selected date with today
            if ( $('#date').val() == $.datepicker.formatDate ( 'mm/dd/yy', now ) ) {
                if ( hour <= now.getHours() ) {
                    return false;
                }
            }
            return true;
        }
    });​
    

    here is a working example :
    http://jsfiddle.net/fgelinas/kUFgT/4/

    As for the start and end hours problem reported by Aymad Safadi, I will see what I can do, this is definitely a bug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having two entity files one as user.php and another as usertype.php. now
hello friends i am having two frames, each frame has a html form which
I'm having trouble validating the uniqueness of two fields, being one of them an
I'm having a bit of an issue solving a jQuery form problem. Basically I
I'm using Jquery with Ruby on Rails (3.1) and am having some problem with
Hey Friends i am having one forms and two button, and some text fields,what
How do you select all fields of two joined tables, without having conflicts with
Having two forms, each in it's own jQuery UI tab, how can I post
I'm having two jquery's that I run and I want to combine them both
I'm having a difficult time understanding how to do this. I have two models,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.