Wednesday 16 April 2014

How to disable Weekend days in DatePicker on ASP.NET using JQuery



In this scenario we need to disable Weekend days. Below is the sample code of JQuery in ASP.NET.

Sample code

<script type="text/javascript">
$(function () {
$("#datepicker").datepicker({ beforeShowDay: $.datepicker.noWeekends });
});
</script>

Example:


Below is the total page design:

<html>
<head>
<title>jQuery Datepicker: Disable all weekends</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: $.datepicker.noWeekends });
});
</script>
</head>
<body>
<form runat="server" id="DesableWeekEnds">
Date:
<asp:TextBox runat="server" ID="datepicker" />
</form>
</body>
</html>


 Output:


No comments:

Post a Comment