Question : jquery datepicker make ALL sunday and monday unselectable

Hello,

I have a question as to whether this is possible before I attempt it.  I have a client company that provides a service for customers that is not available on sundays or mondays.  As a result they would like the datepicker to reflect that by making every monday and sunday unselectable.  Is this possible?

the date picker I currently have is used on an asp.net webform with a master page.  It appears as follows:
    <script type="text/javascript">
        $(function() {
        $("input[id$='txtDate']").datepicker({ showOtherMonths: true, selectOtherMonths: true, showButtonPanel: true, minDate: 1, dateFormat: 'dd/mm/yy' });
        });
      </script>

Thanks in adaznce

Answer : jquery datepicker make ALL sunday and monday unselectable

Here is a working example.  Basically, you apply the beforeShowDay function that will inspect the calendar day.  I've built this to look for day = 0 (Sunday) or day = 1 (Monday) and return false for that, otherwise true.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
      <head>
            <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
			<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
			<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js" type="text/javascript"></script>



			<style>
				* {margin:0;padding:0;}

				html, body
				{

					font-family: Arial;
					font-size: .95em;
					height: 100%;
					width: 100%;
					border: 0;
					padding: 0;
					margin: 0;
					line-height:1em;
					font-weight:normal;
				}

				.checked {border:solid 2px red;}
			</style>




      </head>
</head>

<body>
	<input type="date" id="thisDate" />
	<script type="text/javascript">



		$(document).ready(function(){
			$("#thisDate").datepicker({
				beforeShowDay: function(d){
					var dy = d.getDay();
					if(dy == 0 || dy == 1) {
						return[false,"closed"]
					} else {
						return[true,""]
					}
				}
			});
		});
	</script>

</body>



</html>
Random Solutions  
 
programming4us programming4us