Create A Monthly Calendar For Date Picking - jQuery Osmanli Calendar

File Size: 5.36 KB
Views Total: 5678
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Create A Monthly Calendar For Date Picking - jQuery Osmanli Calendar

Osmanli Calendar is a simple-to-use jQuery plugin to generate a clean-looking, HTML table based monthly calendar for data picking.

Easy to customize by adding your CSS styles to the table cells. Also provides a callback function that will be fired when you select a date.

How to use it:

1. Create an element to hold the current month/year.

<span class="month-year"></span>

2. Create an empty HTML table for the calendar.

<table class="date_table">
  <tr>
    <th>S</th>
    <th>M</th>
    <th>T</th>
    <th>W</th>
    <th>T</th>
    <th>F</th>
    <th>S</th>
  </tr>
</table>

3. Create navigation links to switch between months.

<span class="prev-month">Previous</span>
<span class="next-month">next</span>

4. Load the JavaScript file osmanli_calendar.js after loading jQuery.

<script src="/path/to/cdn/jquery.min.js"></script>
<script src="/path/to/osmanli_calendar.js"></script>

5. Initialize the calendar and we're ready to go.

var start_date_dialog = osmanli_calendar
start_date_dialog.init();

6. Enable the navigation links.

$('.prev-month').click(function () {start_date_dialog.pre_month()});
$('.next-month').click(function () {start_date_dialog.next_month()});

7. Execute a function when you select a date.

start_date_dialog.ON_SELECT_FUNC = function(){
  alert(osmanli_calendar.SELECT_DATE);
}

8. Apply CSS styles to the calendar.

table.date_table {
  /* styles here */
}

table.date_table tr {
  /* styles here */
}

table.date_table td {
  /* styles here */
}

9. Customize the calendar with the following parameters:

// current date
CURRENT_DATE: new Date(),

// selected date
SELECT_DATE:  new Date(),

// min/max dates
MIN_DATE: 'OFF',
MAX_DATE: 'OFF',
DAYS_DISABLE_MAX: 'OFF',
DAYS_DISABLE_MIN: 'OFF',

// callback function
ON_SELECT_FUNC: "OFF",

// used to localize the calendar
content : 'January February March April May June July August September October November December'.split(' '),
weekDayName : 'SUN MON TUES WED THURS FRI'.split(' '),
daysOfMonth : [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],

This awesome jQuery plugin is developed by abhaywani114. For more Advanced Usages, please check the demo page or visit the official website.