Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this datepicker with 5 days range interval but i need to disable saturday and sunday for this datepicker im kinda new to js so i might need a help in this one.

<!DOCTYPE html>


  <div>Please Select Dates:</div>
	 <p>Start Date:</p>
	 <p>End Date:</p>

    $(document).ready(function() {
        var minDate;
        var maxDate;
        var mDate
        var j = jQuery.noConflict();

            onSelect: function() {
                minDate = j("#startTime").datepicker("getDate");
                var mDate = new Date(minDate.setDate(minDate.getDate()));
                maxDate = new Date(minDate.setDate(minDate.getDate() + 4));
                j("#endTime").datepicker("setDate", maxDate);
                j("#endTime").datepicker("option", "minDate", mDate);
                j("#endTime").datepicker("option", "maxDate", maxDate);
        var tdate = new Date();
        var ddate = new Date(tdate.setDate(tdate.getDate() + 4));
        j("#startTime").datepicker("setDate", new Date());
        j("#endTime").datepicker("setDate", ddate);

What I have tried:

i tried to search it up but i can't achieve the desired output
Updated 17-Dec-19 20:21pm

hi your problem is pretty simple. just use this following code.

/* suppose you are trying to disable sunday(0 index),and saturday(6 index) */

    daysOfWeekDisabled: [0,6]

Share this answer
You can also use this way

beforeShowDay: $.datepicker.noWeekends

beforeShowDay: $.datepicker.noWeekends
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900