Created
October 12, 2010 15:48
-
-
Save aaronmcadam/622404 to your computer and use it in GitHub Desktop.
Initialisation code for jQuery UI datepicker widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function() { | |
| $('.datePicker').each(function(){ | |
| var $this = $(this); // cache the this object | |
| $this.keydown( function(event){ | |
| if ( event.keyCode !== 9 ){ // If key is not Tab - for accessibility | |
| event.preventDefault(); // Prevents user input, forces user to use Calendar Date Picker widget | |
| } | |
| }) | |
| .datepicker({ | |
| showOn : 'both', // displays Calendar widget on focus of input and on clicking the Calendar icon | |
| buttonText : 'Choose a date', // Alt text for Calendar icon | |
| buttonImage : '/includes/jqueryCalendar/cal.gif', // source to the Calendar button icon | |
| buttonImageOnly : true, // only show the icon, not the buttonText | |
| dateFormat : 'dd-mm-yy' // format of the date | |
| }); | |
| $this.datepicker( "setDate" , new Date() ); // Prefills the input with the current date to stop form history showing up on click | |
| }); | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Initialisation code for jQuery UI datepicker widget