Click here to Skip to main content
15,895,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to disable all the Sunday,Monday and Wednesday from my jquery date-picker. I am trying to do this using the following code sample-


JavaScript
  jQuery(document).ready(function($) {
  $(".datepicker").datepicker({

 beforeShowDay: function(date) {
        var day = date.getDay();
        return [(day != 1), ''];
    }


  })
});


This code disable all Mondays from the calender. How can i disable all Sunday and Wednesdays too?
Posted

1 solution

Make use of beforeShowDay property:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
<script>
$(function() {
    $( "#datepicker" ).datepicker(
    {
        beforeShowDay: function(d) {
            var day = d.getDay();
            return [(day != 0 && day != 3)];
        }
    });
  });
  </script>
</head>
<body>
<input type="text" id="datepicker">
</body>
</html>
 
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