I have the following ASP.NET MVC form with a datepicker
change event:
<div id="container">
@using (Html.BeginForm("Reload", "DateOfFile", FormMethod.Post, new { returnUrl = this.Request.RawUrl, id = "formDate" }))
{
@(Html.Kendo().DatePicker()
.Name("DateOfFile")
.Value(Session["DateOfFile"] == null ? DateTime.Now : Convert.ToDateTime(Session["DateOfFile"].ToString()))
.Events(e => e
.Change("dt_picker_change")
)
)
@Html.Hidden("returnUrl", this.Request.RawUrl)
<script>
function dt_picker_change() {
$("#container").kendoValidator({
rules: {
dateValidator: function (input) {
var value = $(input).val();
var date = kendo.parseDate(value);
//alert(date)
if (!date) {
return false;
}
$("#formDate").submit();
}
});
}
</script>
}
</div>
In the code above, the form only submitted when I click somewhere outside the DatePicker control, but it need to submit as soon as the date is changed in calendar.
What am I missing?