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();
var currentDate = date.getDate();
var currentYear = date.getFullYear();
$("#<%= tbxRequestDeliveryDate.ClientID %>").datepicker({
changeMonth: true,
changeYear: true,
minDate: new Date(currentYear, currentMonth, currentDate),
beforeShowDay: function (date) {
if (date.getDay() == 0 || date.getDay() == 1 || date.getDay() == 6) {
return [false, ''];
} else {
return [true, ''];
}
}
});
});
</script>
<asp:TextBox ID="tbxRequestDeliveryDate" runat="server" CssClass="text"></asp:TextBox>