jQuery

Date Picker jQuery – How to disable weekdays

Here Laxmikant has explained with an example, Date Picker jQuery – How to disable weekdays.

Basically, Datepicker allows users to click the all weekdays. If you want to block any weekdays
for example : allmost company has holidays on saturday and sunday.
We can appointment with the company except Saturdey and Sunday. In this case we want to block the saturdays and sundays in the datepicker.

Click this link for integrate the jQuery datepicker

Weekdays datepicker values
[php]
Index
0 – Sunday
1 – Monday
2 – Tuesday
3 – Wednesday
4 – Thursday
5 – Friday
6 – Saturday
[/php]

Key Point:
If you want to block any paricular weekday in the datepicker just use the index numbers instead of using the weekdays.
Now will block the Saturday and Sundays then we use the index numbers 6 and 0 . If you want block monday and Tuesdat using the index numbers 1 and 2.

Code for Date Picker jQuery – How to disable weekdays
[php]
<script>
$(document).ready(function () {
$(‘#txtDate’).datepicker({
beforeShowDay:
function (date) {
return [date.getDay() == 0 || date.getDay() == 6 ? false : true];
}
});
});
</script>
[/php]

Output :Date Picker jQuery – How to disable weekdays
block-particular-weekdays-jquery-datepicker

Leave a Reply

Your email address will not be published. Required fields are marked *