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 524043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:31:35+00:00 2026-05-13T08:31:35+00:00

Is there a Javascript or some library that would create a datepicker for a

  • 0

Is there a Javascript or some library that would create a datepicker for a webpage (similar to Jquery UI DatePicker that would only allow certain dates to be clickable and highlighted.

For example on server side, I could specify a array of days to enable to be selected.

  • 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-05-13T08:31:35+00:00Added an answer on May 13, 2026 at 8:31 am

    The Datepicker beforeShowDay() event is intended for exactly this purpose. Here’s an example where the set of allowed dates is relatively small for purposes of illustration. Depending on how many dates you have and how they are chosen, you could instead write a method that programmatically selected dates (say by ignoring weekends, the 1st and 15th of every month, etc). Or you could combine both techniques, say remove weekends and a fixed list of holidays.

    $(function() {
        // this could be a static hash, generated by the server, or loaded via ajax
        // if via ajax, make sure to put the remaining code in a callback instead.
        var dates_allowed = {
              '2009-12-01': 1,
              '2009-12-25': 1,
              '2010-09-28': 1,
              '2011-10-13': 1
        };
    
        $('#datepicker').datepicker({
            // these aren't necessary, but if you happen to know them, why not
            minDate: new Date(2009, 12-1, 1),
            maxDate: new Date(2010, 9-1, 28),
    
            // called for every date before it is displayed
            beforeShowDay: function(date) {
    
                // prepend values lower than 10 with 0
                function addZero(no) {
                    if (no < 10){
                      return "0" + no;
                    }  else {
                      return no; 
                    }
                }
    
                var date_str = [
                    addZero(date.getFullYear()),
                    addZero(date.getMonth() + 1),
                    addZero(date.getDate())      
                ].join('-');
    
                if (dates_allowed[date_str]) {
                    return [true, 'good_date', 'This date is selectable'];
                } else {
                    return [false, 'bad_date', 'This date is NOT selectable'];
                }
            }
        });
    });
    

    The return values are

    [0]: boolean selectable or not,
    [1]: CSS class names to apply if any (make sure to return '' if none),
    [2]: Tooltip text (optional)
    

    Note that the date variable given in the callback is an instance of a Date object representing the given day, not a text version of that date in the specified format. So for instance, you could generate the list of allowable dates in one format while displaying dates in the datepicker in a different format (e.g. so you wouldn’t have to transform dates from a DB when generating the page).

    See also Can the jQuery UI Datepicker be made to disable Saturdays and Sundays (and holidays)?

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

Sidebar

Related Questions

I would like to as some help. Is there a certain method in javascript/jquery
I need to build a small JavaScript library that would only be a couple
There are some third party Javascript libraries that have some functionality I would like
I'm testing some cookies that I'm creating via JavaScript. Is there a way to
Does the Prototype Javascript library have a selector that's equivalent to jQuery's :contains() ?
Our company have a need to set up some solution, that would allow us
Using the jQuery library, not any other JavaScript library, if you were to create
I want develop some web product with using javascript 3d library like three.js But
There are some ARIA tutorial websites use non-semantic markup and some javascript to demostrate
There is a JavaScript function in html <script type=text/javascript> function someFunction(){ return <b>some text</b>;

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.