Click here to Skip to main content
13,189,324 members (64,904 online)
Click here to Skip to main content
Add your own
alternative version


9 bookmarked
Posted 25 Jul 2011

jQueryUI DatePicker: Disable days in a week

, 25 Jul 2011
Rate this:
Please Sign up or sign in to vote.
How to disable days in a week in the jQueryUI DatePicker.

We already know how to use the jQuery UI DatePicker in ASP.NET. Here is a good reference.

I'm working with people who have a need for a DatePicker where users can only select Wednesday, Thursday, and Friday. And in addition, the user will not able to select any past date either. Following are the steps:

Make sure you add the following js and css files.

  • jquery-1.4.1.min.js

  • jquery.ui.core.js

  • jquery.ui.datepicker.js

  • jquery-ui-1.8.8.custom.css

Now paste the following code:

<script type="text/javascript">
    $(function () {
        var date = new Date();
        var currentMonth = date.getMonth(); // current month
        var currentDate = date.getDate(); // current date
        var currentYear = date.getFullYear(); //this year
        $("#<%= tbxRequestDeliveryDate.ClientID %>").datepicker({
            changeMonth: true, // this will allow users to chnage the month
            changeYear: true, // this will allow users to chnage the year
            minDate: new Date(currentYear, currentMonth, currentDate),
            beforeShowDay: function (date) {
                if (date.getDay() == 0 || date.getDay() == 1 || date.getDay() == 6) {
                    return [false, ''];
                } else {
                    return [true, ''];
<asp:TextBox ID="tbxRequestDeliveryDate" runat="server" CssClass="text"></asp:TextBox>


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Monjurul Habib
Software Developer (Senior)
Singapore Singapore
A life-long-learner, maker and soft music fan. Likes building things to solve problems. Years of successful records serving mid and large scale .NET applications in domestic and international client environment. Expertise in different areas of software development life cycles and Software Architecture.

Always looks for new technology and loves to get hands dirty Smile | :)

You may also be interested in...

Comments and Discussions

GeneralNice i was looking for something like this :) Pin
n.podbielski28-Jul-11 5:32
membern.podbielski28-Jul-11 5:32 
GeneralRe: my pleasure. Pin
Monjurul Habib28-Jul-11 11:33
memberMonjurul Habib28-Jul-11 11:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171016.2 | Last Updated 25 Jul 2011
Article Copyright 2011 by Monjurul Habib
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid