Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery UI Datepicker: Disable Specific Days

Nov 26, 2012
Introduction
  
In this
jQuery UI Datepicker article I will explain how to disable specific days in jQuery datepicker.
Description:
  
In previous posts I explained
Disable specific dates in Calendar, Disable Future dates in Calendar, Disable weekends in datepicker, Show multiple months in datepicker and many articles relating to JQuery and datepicker. Now I will explain how to disable specific days in jQuery datepicker.

To disable specific days in datepicker we need to write the code like as shown below

$(function() {
$("#datepicker").datepicker({ beforeShowDay: function(date) {
var day = date.getDay();
return [(day != 1 && day != 3)];
}
});
});
If you want to see it in complete example needs to write below code in your page


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>jQuery Datepicker: Disable Particular Dates</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker({ beforeShowDay: function(date) {
var day = date.getDay();
return [(day != 1 && day != 3)];
}
});
});
</script>

</head>
<body>
<p>Date: <input type="text" id="datepicker" /></p>
</body>
</html>
Demo

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

8 comments :

Unknown said...

Hello suresh ji !!
You are doing very good work.
please teach us WCF and i earlier also requested you.
pLease sir!!!

Vipin Kumar Pandey

Unknown said...

Please tell me how to use validation for n number of generated textboxes.

WangWashington said...

Any time your post is always new and helpful for asp.net developer.thanks for sharing and keep sharing more.

Unknown said...

Thanks Sir...
It's very helpfull...

Unknown said...
This comment has been removed by the author.
Unknown said...

Hello sir
I want to disable two dates(1,3). So I modified your code like this..

$(function() {
$("#datepicker").datepicker({ beforeShowDay: function(date) {
var day = date.getDate();
return [(day != 1 && day != 3)];
}
});
});

and It works.
but if I want to fetch dates(1 Nov 2012, 3 Nov 2012) from sql server database table then How can I do this?

Murugavel Sadagopan said...

Hi,

I want to disable the days from DB (non_working_days table)

Thanks,
Murugavel S

Anonymous said...

Dear Sir,
I want to set range of min amd max date in datepicker via database values.How to do so kindly help.

My name is Avinash Sureka

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.