Cool light visual date picker using native JavaScript
Browsers support: Chrome 45+, FireFox 40+, Safari 8+, IE10+ (since 1.0.1 version), iOS Safari 8+, Android Browser 4.4+
You need to include library javascript and CSS files from dist directory on your page
<link rel="stylesheet" href="dist/css/DatePickerX.min.css">
<script src="dist/js/DatePickerX.min.js"></script>The DatePickerX extends HTMLInputElement objects through prototypes. It adds DatePickerX object for each input element.
You need just select HTML element and execute init method for date picker initializing.
document.getElementById('myInputId').DatePickerX.init();Each DatePickerX object contains the following methods:
init( [Object options] )- initializes date picker. May take object with initialization optionsremove()- removes date pickersetValue( Date dt, [Boolean ignoreLimits = false] )- sets date picker valuegetValue( [Boolean timestamp = false] )- returns formatted date picker value or timestamp if passed true in first parametergetMinDate()- returns min date of date pickergetMaxDate()- returns max date of date picker
Also DatePickerX provides global DatePickerX object with following methods:
window.DatePickerX.setDefaults( Object options )- sets default options for all date pickers
mondayFirst- iftrue, set Monday as start week day. Default:trueformat- date format. It's being used for formatting input values and returned values fromgetValuemethods. Default:yyyy/mm/dd. Supports following literals:d- day of the month without leading zeros (1-31)dd- day of the month with leading zeros (01-31)D- textual representation of week day. SeeweekDayLabelsoptionm- numeric representation of a month without leading zeros (1-12)mm- numeric representation of a month with leading zeros (01-12)M- short textual representation of a month. SeeshortMonthLabelsoptionMM- full textual representation of a month. SeesingleMonthLabelsoptionyy- two-digits representation of a yearyyyy- four-digits representation of a year
minDate- minimum date limit. Should be aDateobject ornull(no limit). Also you may pass another DatePickerX HTML input which selected date will be set as min date dynamicallymaxDate- maximum date limit. Should be aDateobject. Also you may pass another DatePickerX HTML input which selected date will be set as min date dynamicallyweekDayLabels- array with textual representation of week days starting with Monday. SeeDliteral forformatoption. Default:['Mo', 'Tu', 'We', 'Th', 'Fr', 'St', 'Su']shortMonthLabels- array with textual representation of short month names. SeeMliteral forformatoption. Default:['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']singleMonthLabels: array with textual representation of full month names. SeeMMliteral forformatoption. Default:['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']todayButton- iftruetoday button should be enabled. Current date will be set as date picker value by clicking this button. Default:truetodayButtonLabel- today button label. Default:'Today'clearButton- iftrueclear button should be enabled. Date picker value will be cleared by clicking this button. Default:trueclearButtonLabel- clear button label. Default:'Clear'