This is a migrated thread and some comments may be shown as answers.
Validation not working as expected
1 Answer 135 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
PaulMrozowski asked on 17 Jul 2012, 11:50 PM
I have a model that includes a DateTime field. It has a "[Required]" attribute on the property. My .cshtml file includes this:

    .DatePickerFor(p => p.CashReceipt.ReceivedOn)
    .HtmlAttributes(new { type = "text" })                                               

I'm not seeing the HTML attributes rendered into the output that I would expect, ex. data-val-required, etc.

I copied over the EditorTemplates from the sample project, then created a clean page to help isolate the problem. Instead of using the above, I tried this:

@Html.EditorFor(p => p.CashReceipt.ReceivedOn)

When this page runs, I see the validation attributes in the HTML as expected, however the JS on the page fails with "Uncaught TypeError: Object [object Object] has no method 'kendoDateTimePicker' "

I thought it might be because I have all of my JS references at the bottom of the page (to speed up page rendering), so I tested them at the top - I get the same error. 

<script src="" type="text/javascript"></script
<script type="text/javascript" src="/Scripts/modernizr-1.7.min.js"></script>
<script type="text/javascript" src="/Scripts/jquery.validate.min.js"></script>
<script type="text/javascript" src="/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script type="text/javascript" src="/Scripts/knockout-2.0.0.js"></script>
<script type="text/javascript" src="/Scripts/kendo.web.min.js"></script>
<script type="text/javascript" src="/Scripts/kendo.aspnetmvc.min.js"></script>
<script type="text/javascript" src="/Scripts/knockout-kendo.min.js"></script>

So the big question is - how do I make this work? More specifically, how do I make this work without just hardcoding the attributes in via the HtmlAttributes() method?

1 Answer, 1 is accepted

Sort by
Georgi Krustev
Telerik team
answered on 20 Jul 2012, 09:10 AM
Hello Paul,

When try to render editor for property of nested model (CachReciept) the DatePicker will not render the validation attributes. This is a known issue and will be addressed in the next internal build of the KendoUI.
As to the JavaScript error, I could not see where the jQuery JS file is included. Please note that the KendoUI has dependency to the jQuery.

Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Asked by
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question