Reputation: 158
I m using the little time kendo and found a problem in validating the datepicker.
@using (Ajax.BeginForm("FindByFilter", "Find", new { filter = Model.Filter }, new AjaxOptions { UpdateTargetId = "content", HttpMethod = "GET", InsertionMode = InsertionMode.Replace }))
{
<div class="demo-section fr" style="width: 340px; margin-top: -2px;">
<label for="start">Start:</label>
@(Html.Kendo().DatePickerFor(model => model.Filter.Start)
.Name("start")
.Culture("pt-BR")
.HtmlAttributes(new { style = "width: 140px" })
.Min(DateTime.Today)
.Events(e => e.Change("startChange"))
)
<label for="end" style="margin-left: 0.5em">End:</label>
@(Html.Kendo().DatePickerFor(model => model.Filter.End)
.Name("end")
.Culture("pt-BR")
.HtmlAttributes(new { style = "width: 140px" })
.Min(Model.Filter.Start)
.Events(e => e.Change("endChange"))
)
</div>
<div>
<input type="submit" class="button small secondary lupa fr" />
</div>
}
When I click the submit the datepicker does not accept the format 20/04/2013 only in the format 2013-04-20. I set the culture to pt-BR, but validation is still occurring. Can anyone help?
Upvotes: 0
Views: 4106
Reputation: 2880
I seem to remember having exactly the same issue. Like you we changed the culture by using kendo.culture('en-GB') but this didn't resolve the issue. In the end we had to add our own jQuery validator method:
jQuery.validator.addMethod(
'date',
function (value, element) {
if (this.optional(element)) {
return true;
};
var result = false;
try {
$.datepicker.parseDate('dd/mm/yy', value);
result = true;
} catch (err) {
result = false;
}
return result;
},
''
);
Upvotes: 1