Monday, October 12, 2015

JQuery (Mobile) Date picker



JQuery (Mobile) Date picker

One day I wanted to find a date picker like iOS native date selector for a JQuery mobile project. Unfortunately I couldn't find any date picker for my requirement even though I searched all over the internet. So I decided to develop a plugin by myself.

Date picker


HTML input tag
 <input id='datepicker' type="text" />

Script :
  jQuery("#datepicker").dateSelector({
                        onChange: function(date) {
                            var currDate = formatDate(date);                          
                        }
                    });

Default options:
position: "C", // T-top C-center B-bottom I-inline
selectedDate: new Date(), // today
maxDate: null,
minDate: null,
dateFmt: "MM/dd/yyyy",
dmyOrder: "MDY", // Month Day Year
monthFormat: "NNN", // MM,MMM,NNN (02,February,Feb)
onChange: function(date) {} // Empty function

You can download the plugin from my google drive


References:
swipedown swipeup Events:  www.adomas.org
dateFormat: www.mattkruse.com

No comments:

Post a Comment