title | page_title | description |
---|---|---|
DateInput |
Configuration, methods and events of Kendo UI DateInput |
Easy to follow steps guide how to quickly configure DateInput UI widget, easily enable/disable it using methods and how to change events. |
Represents the Kendo UI DateInput widget. Inherits from Widget.
Specifies the format, which is used to format the value of the DateInput displayed in the input. The format also will be used to parse the input.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput({
format: "yyyy/MM/dd"
});
</script>
Specifies the maximum date which can be entered in the input.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput({
max: new Date(2013, 0, 1) // sets max date to Jan 1st, 2013
});
</script>
Specifies the minimum date that which be entered in the input.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput({
min: new Date(2011, 0, 1) // sets min date to Jan 1st, 2011
});
</script>
Specifies the selected date.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput({
value: new Date(2011, 0, 1)
});
</script>
The messages that DateInput uses. Use it to customize or localize the placeholders of each date/time part.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput({
messages:{
"year": "year",
"month": "month",
"day": "day",
"weekday": "day of the week",
"hour": "hours",
"minute": "minutes",
"second": "seconds",
"dayperiod": "AM/PM"
}
});
</script>
The placeholder for the years part.
The placeholder for the months part.
The placeholder for the day of the month part.
The placeholder for the day of the week part.
The placeholder for the hours part.
The placeholder for the minutes part.
The placeholder for the seconds part.
The placeholder for the AM/PM part.
An object, which holds the options of the widget.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput();
var dateinput = $("#dateinput").data("kendoDateInput");
var options = dateinput.options;
<script>
Prepares the DateInput for safe removal from DOM. Detaches all event handlers and removes jQuery.data attributes to avoid memory leaks. Calls destroy method of any child Kendo widgets.
Important: This method does not remove the DateInput element from DOM.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput();
var dateinput = $("#dateinput").data("kendoDateInput");
// detach events
dateinput.destroy();
</script>
Enable/Disable the DateInput widget.
The argument, which defines whether to enable/disable the DateInput.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput();
var dateinput = $("#dateinput").data("kendoDateInput");
dateinput.enable(false);
</script>
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput();
var dateinput = $("#dateinput").data("kendoDateInput");
dateinput.enable(true);
</script>
Toggles the readonly state of the widget. When the widget is readonly it doesn't allow user input.
There is a difference between disabled and readonly mode. The value of a disabled widget is not posted as part of a
form
whereas the value of a readonly widget is posted.
The argument, which defines whether the DateInput should be readonly or editable.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput();
var dateinput = $("#dateinput").data("kendoDateInput");
dateinput.readonly();
</script>
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput();
var dateinput = $("#dateinput").data("kendoDateInput");
dateinput.readonly(false);
</script>
Gets/Sets the max value of the DateInput.
The max date to set.
Date
The max value of the DateInput.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput();
var dateinput = $("#dateinput").data("kendoDateInput");
var max = dateinput.max();
console.log(max);
</script>
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput();
var dateinput = $("#dateinput").data("kendoDateInput");
dateinput.max(new Date(2100, 0, 1));
</script>
Gets/Sets the min value of the DateInput.
The min date to set.
Date
The min value of the DateInput.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput();
var dateinput = $("#dateinput").data("kendoDateInput");
var min = dateinput.min();
console.log(min);
</script>
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput();
var dateinput = $("#dateinput").data("kendoDateInput");
dateinput.min(new Date(2000, 0, 1));
</script>
Changes the initial DateInput configuration.
The new configuration options.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput({
min: new Date(2001, 0, 1),
max: new Date()
});
var dateinput = $("#dateinput").data("kendoDateInput");
dateinput.setOptions({
min: new Date(2010, 5, 6)
});
</script>
Gets/Sets the value of the DateInput.
The value to set.
Date
The value of the DateInput.
- This method does not trigger change event. This could affect MVVM value binding. The model bound to the widget will not be updated. You can overcome this behavior trigerring the
change
event manually using trigger("change") method.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput();
var dateinput = $("#dateinput").data("kendoDateInput");
dateinput.value(new Date(2016, 10, 1));
dateinput.trigger("change");
</script>
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput({
value: new Date(2013, 10, 10)
});
var dateinput = $("#dateinput").data("kendoDateInput");
var value = dateinput.value();
console.log(value);
</script>
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput({
value: new Date(2013, 10, 10)
});
var dateinput = $("#dateinput").data("kendoDateInput");
dateinput.value(new Date());
</script>
Fires when the selected date is changed
The widget instance which fired the event.
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput({
change: function() {
var value = this.value();
console.log(value); //value is the selected date in the dateinput
}
});
</script>
<input id="dateinput" />
<script>
$("#dateinput").kendoDateInput();
var dateinput = $("#dateinput").data("kendoDateInput");
dateinput.bind("change", function() {
var value = this.value();
console.log(value); //value is the selected date in the dateinput
});
</script>