0

Need a calendar script in Javascript or Jquery which should have the option like disabling all the previous dates from the current date and also disable the Saturday's and Sunday's too

Developer
  • 8,390
  • 41
  • 129
  • 238

2 Answers2

1

you can use jquery ui datepicker

  1. you can disable previous dates, by using minDate and maxDate options
  2. check this out disabling Saturdays and Sundays
Community
  • 1
  • 1
ianace
  • 1,646
  • 2
  • 17
  • 31
  • I am not much familiar with jquery and javascript so can you tell Where can i exactly paste that content – Developer Apr 13 '11 at 10:19
  • you can do something like this inside your js file `$( ".selector" ).datepicker( "option", "minDate", new Date(2007, 1 - 1, 1) );` where `".selector"` is the element that you want the calendar view to pop out – ianace Apr 13 '11 at 10:24
0

Here is a very simple calendar script in javascript:

<table border="1">
<tr>
  <td>M</td> <td>T</td> <td>W</td> <td>T</td> <td>F</td> <td>S</td> <td>S</td>
</tr>

<script language="JavaScript"> <!--

// find the first day of the current month
function firstDay() {
   d = new Date();   // d is today's date
   d.setDate(1);     // set d to the 1st of this month
   day = d.getDay(); // day of week - 0=Sunday, 1=Monday... etc.
   if (day==0) {
      return 6;
   } else {
      return day-1;
   }
}

var week = 0; // week of the month
var weekDay = 0; // day of the week
var day; // day of the month
var startingDay = firstDay(); // day the month starts, 0 to 6 

for (week=0; week<=5; week++) {
   document.write("<tr>");
   for (weekDay=1; weekDay<=7; weekDay++) {
      document.write("<td>");
      day = 7*week+weekDay;
      day -= startingDay;
      if (day>0 && day<=31) { document.write(day); }
      document.write("</td>");
   }
   document.write("</tr>");
}

--> </script>

<table>

It's not disabling past dates or week-ends but it's so simple that you will probably be able to adapt it.

boisvert
  • 3,679
  • 2
  • 27
  • 53