Extend from $.fn.combo.defaults. Override defaults with $.fn.datebox.defaults
The datebox combines a editable text box with drop-down calendar panel that allows the user to select a date. The entered string in the text box can be transformed to a valid date. The selected date can also be formatted as expected.
Create datebox from markup.
Create datebox using javascript.
The properties extend from combo, below is the added properties for datebox.
Name | Type | Description | Default |
---|---|---|---|
panelWidth | number | The drop down calendar panel width. | 180 |
panelHeight | number | The drop down calendar panel height. | auto |
currentText | string | The text to display for the current day button. | Today |
closeText | string | The text to display for the close button. | Close |
okText | string | The text to display for the ok button. | Ok |
disabled | boolean | When true to disable the field. | false |
formatter | function |
A function to format the date, the function take a 'date' parameter and return a string value.
The example below shows how to override the default formatter function.
$.fn.datebox.defaults.formatter = function(date){ var y = date.getFullYear(); var m = date.getMonth()+1; var d = date.getDate(); return m+'/'+d+'/'+y; } |
|
parser | function |
A function to parse a date string, the function take a 'date' string and return a date value.
The example below shows how to override the default parser function.
$.fn.datebox.defaults.parser = function(s){ var t = Date.parse(s); if (!isNaN(t)){ return new Date(t); } else { return new Date(); } } |
Name | Parameters | Description |
---|---|---|
onSelect | date |
Fires when user select a date.
Code example: $('#dd').datebox({ onSelect: function(date){ alert(date.getFullYear()+":"+(date.getMonth()+1)+":"+date.getDate()); } }); |
The methods extend from combo, below is the overridden methods for datebox.
Name | Parameter | Description |
---|---|---|
options | none | Return the options object. |
calendar | none |
Get the calendar object.
The example below shows how to get the calendar object and then recreate it.
// get the calendar object var c = $('#dd').datebox('calendar'); // set the first day of week to monday c.calendar({ firstDay: 1 }); |
setValue | value |
Set the datebox value.
Code example: $('#dd').datebox('setValue', '6/1/2012'); // set datebox value var v = $('#dd').datebox('getValue'); // get datebox value |