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 Past Dates Days

Nov 18, 2012
Introduction
  
Here I will explain how to disable past or previous dates in
jQuery datepicker.
Description:
  
In previous posts I explained Disable weekends in jQuery datepicker,
Show multiple months in datepicker, Show datepicker on button click and many articles relating to JQuery and datepicker. Now I will explain how to disable past dates in jQuery datepicker.

To disable past dates in datepicker we need to write the code like this


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>jQuery Datepicker: Disable past days</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() {
var date = new Date();
var currentMonth = date.getMonth();
var currentDate = date.getDate();
var currentYear = date.getFullYear();
$('#datepicker').datepicker({
minDate: new Date(currentYear, currentMonth, currentDate)
});
});
</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

13 comments :

Anonymous said...

great man !

Unknown said...

plz could u send the code to me of this post
jQuery UI Datepicker Disable Past Dates Days

Anonymous said...

Thanks.........
It working

Unknown said...

working like a charm.....thank you

Dilip said...

it is working, thank you so much :)

Anonymous said...

can i hide today's date also ?? i want to show from tomorrow's date. is it possible ??

Anonymous said...

got it, its date.getDate() + 1;

Thank you for the Post BDW

Unknown said...

how do i change the date forma\t in above query?

Ankur said...

Hi Rajesh
You can change the date format also by giving , then write down dateFormat:"dd/mm/yy" like below

$(function() {
var date = new Date();
var currentMonth = date.getMonth();
var currentDate = date.getDate();
var currentYear = date.getFullYear();
$('#depart').datepicker({
minDate: new Date(currentYear, currentMonth, currentDate),
dateFormat: "dd/mm/yy" });
});

Unknown said...

Good

Unknown said...

Can i disable next days dates?

Anonymous said...

i tried the code its not working , i included the css in master page, and i have asp.net textbox

Anonymous said...

Wow this is working, thanks

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.