Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Okay, So I have a Kendo Grid where two of the columns are of type date. I want to restrict the entered keys in the date field to only 10 digits. I tried putting @maxlength="10" in HtmlAttributes but it's not working.

But this works when we have an explicit datepicker example:-
JavaScript
@(Html.Kendo().DatePickerFor(x=>x.NotificationDate).Name("NotificationDate").Format("MM/dd/yyyy").Max(DateTime.Today)
                                .HtmlAttributes(new
                                {
                                    id = "NotificationDate",
                                    @onkeypress = "return acceptDateFormat(event)",
                                    @onchange = "ValidateDate('NotificationDate', true)",
                                    @maxlength = "10",
                                    @type = "datetime"
                                }))


Here, it works. But not the place where I want to.
Kindly help me out with this.

What I have tried:

JavaScript
columns.Bound(c => c.DueDate).Title("Due").Format("{0:MM/dd/yyyy}").Width(120).HtmlAttributes(new
            {
                @onkeypress = "return acceptDateFormat(event)",
                @maxlength = "10",
                @type = "datetime"
            });
            columns.Bound(c => c.CompletedDate).Title("Completed").Format("{0:MM/dd/yyyy}").Width(120).HtmlAttributes(new
            {
                @onkeypress = "return acceptDateFormat(event)",
                @maxlength = "10",
                @type = "datetime"
            });
Posted
Updated 11-Dec-18 4:42am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900