Need help assigning a max date value to my Kendo DatePicker control

Hi Experts,
I have an MVC.Net application with C# code behind.
I need help assigning a max date value to my Kendo UI control.
I want the max date to be the current date.  I have tried some code but it's not working (see code below).
What can I do to make this work?

CURRENT CODE THATS NOT WORKING
<script>
    $(document).ready(function () {
        var today = new Date();
        var maxDate = todayx.setDate(today.getDate());

        $("#EndDate").kendoDatePicker({
            max: new Date(maxDate)
        });
    });
</script>


    <table class="aTable" border="0">
        <tr class="aRow">
            <td class="right1">
                To:&nbsp;
                @(Html.Kendo().DatePicker().Name("EndDate")
                .HtmlAttributes(new { @class = "dataPickerStyle", title = "End Date" }))
            </td>
        </tr>
    </table>

Open in new window


Thank you in advance,
mrotor
mainrotorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
try change:

var maxDate = todayx.setDate(today.getDate());

Open in new window


to:

var maxDate = today.getDate();

Open in new window

0
Flabio GatesCommented:
I do not know what Kendo is but what is todayx?
Can you try the following?
<script>
    $(document).ready(function () {
        var today = new Date();

        $("#EndDate").kendoDatePicker({
            max: today
        });
    });
</script>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mainrotorAuthor Commented:
Hi Flabio and Ryan,
I tried both our your suggestions but it still not working.

Sorry that the todayx in m y code caused confusion.  It was left there accidently.  I thought I had cleaned up my code.
This is how my code should look like after further clean up. Ha ha.

<script>
    $(document).ready(function () {
        var today = new Date();
        var maxDate = today.setDate(today.getDate());

        $("#EndDate").kendoDatePicker({
            max: new Date(maxDate)
        });
    });
</script>


    <table class="aTable" border="0">
        <tr class="aRow">
            <td class="right1">
                To:&nbsp;
                @(Html.Kendo().DatePicker().Name("EndDate")
                .HtmlAttributes(new { @class = "dataPickerStyle", title = "End Date" }))
            </td>
        </tr>
    </table>

Open in new window

0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Ryan ChongCommented:
I didn't use kendoDatePicker but I think Flabio's solution should work for you...

<script>
    $(document).ready(function () {
        var today = new Date();

        $("#EndDate").kendoDatePicker({
            max: today
        });
    });
</script>
0
mainrotorAuthor Commented:
Flabio's solution didn't work for me. :-(
0
Flabio GatesCommented:
Apparently, Kendo is a non-free JQuery plugin. Best you ask their support page.
0
Ryan ChongCommented:
will this help?

<input id="datepicker" />
<script>
$("#datepicker").kendoDatePicker({
    max: new Date(2013, 0, 1) // sets max date to Jan 1st, 2013
});
</script>

Open in new window


Ref: https://docs.telerik.com/kendo-ui/api/javascript/ui/datepicker#configuration-max
0
Flabio GatesCommented:
Question inactive
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
UI/UX

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.