jQuery.fn.glowDateTimeSelector
This plugin decorates a text input for use as a formatted date and time input with an optional calendar date selector.
Usage
Initiate a selection of text inputs to be date time selectors.
$('selector').glowDateTimeSelector(options)
where selector contains <input type="text" />
element(s) and options
is an optional object argument
Options
-
pattern
: string pattern containing all desired segments of a date+time string along with their possible values.- default: Empty String
- Examples:
"<00-23>:<00-59>"
"<Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec> <1-31>, <1900-3000>"
"<January,February,March,April,May,June,July,August,September,October,November,December> <1-31>, <1900-3000> at <1-12>:<00-59> <am,pm>"
-
yearIndex
: integer index of where, in a whitespace-split value string, the year is expected to be parsed. When < 0, default parsing is used.- default: -1
-
monthIndex
: integer index of where, in a whitespace-split value string, the month is expected to be parsed. When < 0, default parsing is used.- default: -1
-
dayIndex
: integer index of where, in a whitespace-split value string, the day is expected to be parsed. When < 0, default parsing is used.- default: -1
-
hourIndex
: integer index of where, in a whitespace-split value string, the hour is expected to be parsed. When < 0, default parsing is used.- default: -1
-
minuteIndex
: integer index of where, in a whitespace-split value string, the minute is expected to be parsed. When < 0, default parsing is used.- default: -1
-
amPmIndex
: integer index of where, in a whitespace-split value string, am or pm is expected to be parsed. When < 0, default parsing is used.- default: -1
-
allowBlankvalue
: boolean value of whether or not to allow an empty date- default: true
-
monthNames
: Array of string names of months to use in calendar popups.- default: Evolution-provided localized strings.
-
dayNames
: Array of string names of weekday names to use in calendar popups.- default: Evolution-provided localized strings.
-
previousButtonCssClass
: string classname applied to next buttons within a calendar popup- default: empty string
-
nextButtonCssClass
: string classname applied to previous buttons within a calendar popup- default: empty string
-
parseDateOnLoad
: bool identifying whether the value of the textbox should be parsed as a javascript date (true) or treated as the target pattern (false)- default: false
-
clearText
: text to show when a date can be cleared.- default: 'Clear'
-
selectText
: text to show to commit a date selection.- default: 'OK'
Events
glowDateTimeSelectorChange
: triggered when the value is changed
Methods
The glowDateTimeSelector
's initiation is delayed from its use by 9 ms. To use 'val'
or 'disabled'
immediately after applying glowDateTimeSelector()
to a selection, it requires delaying the call by 10 ms or more. This is not required when calling 'val'
or 'disabled'
in response to user interaction.
val
Retrieves and/or sets the current value of the date time selector. The value of the selected text input is also updated by the date time selector.
// get the current datetime as a Date object
var date = $('selector').glowDateTimeSelector('val');
// set the current datetime to a date object value
$('selector').glowDateTimeSelector('val', new Date());
disabled
Retrieves and/or sets whether the date time selector is disabled. When enabled, focusing on the input will allow changing the value. When disabled, it will not.
// get the current disabled state
var isDisabled = $('selector').glowDateTimeSelector('disabled');
// set the disabled state
$('selector').glowDateTimeSelector('disabled', false);