Skip to content
A javascript datepicker
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
index.html
jsdatepicker.css
jsdatepicker.js
main.css

README.md

jsdatepicker

A simple and easy to customise javascript datepicker.

Demo

How to use

Include the neccesary stylesheet and javascript files:

<link rel="stylesheet" type="text/css" href="jsdatepicker.css" media="screen" />
<script src='jsdatepicker.js'></script>

Include a simple div to hold your datepicker:

<div id="my-date-picker" class="js-date-picker"></div>

Initialise the date picker (e.g. with the current date):

<script>
	var date = new Date();
	var year = date.getFullYear();
	var month = date.getMonth();
	
    var datePicker = new JSDatePicker('my-date-picker',month,year);
    datePicker.onPickedDate(function(day,month,year) {
			console.log('Picked day '+day+'/'+month+'/'+year);
    });	
</script>

Public methods

onPickedDate(handler)

handler

Type: Function(element, day, month, year)

A function to execute when a date is picked. The element is the day element clicked. day, month and year is the selected date.


getSelectedDate()

Returns an array ([day, month, year]) representation of the current selected date. If no date is selected array value is [-1, -1, -1].

You can’t perform that action at this time.