In this article I will explain how to disable previous
days in Datapicker on ASP.NET using JQuery.
Or
How to disable past days in Datepicker on ASP.NET using JQuery.
Or
How to disable past days in Datepicker on ASP.NET using JQuery.
In this scenario we need to disable previous days of
the current day. Below is the sample code of JQuery in ASP.NET.
JQuery Datepicker code:
<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>
Example:
Below is the total page design:
<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>
<form runat="server" id="DesablePrevious">
Date:
<asp:TextBox runat="server" ID="datepicker" />
</form>
</body>
</html>
Output:
No comments:
Post a Comment