Tuesday, October 18, 2011

Adding Calendar control using jQuery

The jQuery UI Datepicker is a highly configurable plugin that adds datepicker functionality to your pages. You can customize the date format and language, restrict the selectable date ranges and add in buttons and other navigation options easily.
By default, the datepicker calendar opens in a small overlay onFocus and closes automatically onBlur or when a date is selected. For an inline calendar, simply attach the datepicker to a div or span.
You can use keyboard shortcuts to drive the datepicker:
  • page up/down - previous/next month
  • ctrl+page up/down - previous/next year
  • ctrl+home - current month or open when closed
  • ctrl+left/right - previous/next day
  • ctrl+up/down - previous/next week
  • enter - accept the selected date
  • ctrl+end - close and erase the date
  • escape - close the datepicker without selection

DEMO: How to Add Calendar using jQuery.

Click on textbox to select date

Source code:

<!DOCTYPE html>

      <link href="" rel="stylesheet" type="text/css"/>
      <script type="text/javascript" src=""></script>
          <link rel="stylesheet" href="" type="text/css" media="all" />
      <script src="" type="text/javascript"></script>
      $(document).ready(function() {
            $( "#dtpicker" ).datepicker( "option", "dateFormat", "D, d M, yy" );
            <p> Click on textbox to select date</p>
        <input type="text" id="dtpicker" width="400px"/>

No comments:

Post a Comment