Hello,
I noticed that you can set the value of the date picker using a date or a string with the proper format. If i use the date, I'm getting a different behaviour form the string, when I first put the text to the input
I have created the control with a change event option.
I'm setting the value of the control this way:
datepicker.value(new Date());
when i'm writing some invalid date in the input, the expected behaviour will be that the change event is not executed. But it's being executed.
I tested it with setting the value with a string:
datepicker.value("1/9/2011");
and the result is the expected. the event is not executed.
example:
<div id="Div6" class="k-content">
<div id="email-settings">
<div id="test" style="margin-top: -6px; margin-left: 180px">
<input id="datepicker" style="width:150px;" />
</div>
<div style="margin-top: 59px; margin-left: 180px">
<input id="monthpicker" value="10/10/2011" style="width:150px" />
</div>
</div>
<script>
$(document).ready(function () {
// create DatePicker from input HTML element
$("#datepicker").kendoDatePicker({
change: function () {
// get widget
var widget = this;
alert("datepicker");
}
});
$("#monthpicker").kendoDatePicker({
change: function () {
// get widget
var widget = this;
alert("monthpicker");
}
});
var datepicker = $("#datepicker").data("kendoDatePicker");
var a = "1/9/2011";
datepicker.value(a);
var monthpicker = $("#monthpicker").data("kendoDatePicker");
var b = new Date();
monthpicker.value(b);
});
</script>
Regards
I noticed that you can set the value of the date picker using a date or a string with the proper format. If i use the date, I'm getting a different behaviour form the string, when I first put the text to the input
I have created the control with a change event option.
I'm setting the value of the control this way:
datepicker.value(new Date());
when i'm writing some invalid date in the input, the expected behaviour will be that the change event is not executed. But it's being executed.
I tested it with setting the value with a string:
datepicker.value("1/9/2011");
and the result is the expected. the event is not executed.
example:
<div id="Div6" class="k-content">
<div id="email-settings">
<div id="test" style="margin-top: -6px; margin-left: 180px">
<input id="datepicker" style="width:150px;" />
</div>
<div style="margin-top: 59px; margin-left: 180px">
<input id="monthpicker" value="10/10/2011" style="width:150px" />
</div>
</div>
<script>
$(document).ready(function () {
// create DatePicker from input HTML element
$("#datepicker").kendoDatePicker({
change: function () {
// get widget
var widget = this;
alert("datepicker");
}
});
$("#monthpicker").kendoDatePicker({
change: function () {
// get widget
var widget = this;
alert("monthpicker");
}
});
var datepicker = $("#datepicker").data("kendoDatePicker");
var a = "1/9/2011";
datepicker.value(a);
var monthpicker = $("#monthpicker").data("kendoDatePicker");
var b = new Date();
monthpicker.value(b);
});
</script>
Regards