Date Field
The date
field.
The Date Field uses the Bootstrap Datetime picker under the hood. You can learn more about the picker at it's GitHub project page: https://github.com/Eonasdan/bootstrap-datetimepicker.
For more information on date and time formatting strings, see the Moment.js documentation: http://momentjs.com/docs/.
With this control, you can pass any of the bootstrap-datetimepicker options information through to the underlying control via the options.picker
setting.
Properties
Title | Date |
Description | Date |
Field Type | date |
Base Field Type | text |
Schema
Property | Type | Default | Description |
---|---|---|---|
allowOptionalEmpty | Allows this non-required field to validate when the value is empty | ||
autocomplete | string | Allows you to specify the autocomplete attribute for the underlying input control whether or not field should have autocomplete enabled. | |
data | object | Allows you to specify a key/value map of data attributes that will be added as DOM attribuets for the underlying input control. The data attributes will be added as data-{name}='{value}'. | |
disallowEmptySpaces | boolean | Whether to disallow the entry of empty spaces in the text | |
disallowOnlyEmptySpaces | boolean | Whether to disallow the entry of only empty spaces in the text | |
enum | array | List of specific values for this property | |
format | string | date | Property data format |
inputType | string | Allows for the override of the underlying HTML5 input type. If not specified, an assumed value is provided based on the kind of input control (i.e. 'text', 'date', 'email' and so forth) | |
maskString | string | Expression for the field mask. Field masking will be enabled if not empty. | |
placeholder | string | Field placeholder. | |
size | number | 40 | Field size. |
trim | boolean | Remove whitespace from the beginning and end of string | |
typeahead | Provides configuration for the $.typeahead plugin if it is available. For full configuration options, see: https://github.com/twitter/typeahead.js |
Options
Property | Type | Default | Description |
---|---|---|---|
dateFormat | string | Date format (using moment.js format) | |
name | string | Field Name. | |
picker | any | Options that are supported by the Bootstrap DateTime Picker. | |
sort | function | Defines an f(a,b) sort function for the array of enumerated values [{text, value}]. This is used to sort enum and optionLabels as well as results that come back from any data sources (for select and radio controls). By default the items are sorted alphabetically. Don't apply any sorting if false. |
Example 1
schema and uses the format
schema setting to specify that the value should be a date. Alpaca renders a date field by default and assumes the American format of MM/DD/YYYY
.
Example 2
formatting options. In this example, we switch to using a simplified European date format of DD/MM/YY
. Here we also skip the schema.format
method and specifically spell out that we'd like a date
field control. The format is passed to the underlying DateTimePicker control directly via the picker
option.
In addition, the manualEntry
option is set to false to prevent manual entry of date values into the text field. The picker is therefore required to enter the date.
Example 3
Here is an example of a date field that is invalid. By default, the date format is MM/DD/YYYY. As such, the validation check will determine that the value of this date field is invalid.
The hideInitValidationError
setting is provided but it isn't necessary since it defaults to false
anyway for editable views. You can set it to true
to hide the initial validation message.
Example 4
and also explicitly say that we want a date
field (as opposed to having Alpaca figure that out from the schema format).
Example 5
fields in a display-only mode. Nothing is editable, including the date.
Example 6
option. Take a look at all of the available options on the Bootstrap DateTime Picker plugin page.
Here is an example that limits the calendar. The minimum date is two weeks ago. The maximum date is two weeks from now. And we switch the language to Spanish.
Example 7
Unix epoch convention. This is a milliseconds value with an assumed timezone of UTC.