This is a migrated thread and some comments may be shown as answers.
RadDateInput maxDate
4 Answers 26 Views
This is a migrated thread and some comments may be shown as answers.
Andrew Currie
Top achievements
Rank 1
Andrew Currie asked on 18 Nov 2009, 03:31 PM
Hi all,

Can anyone tell me why the following javascript is not working?

        document.body.onload = function() {

            var txtDOB = document.getElementById("<%= txtDOB.ClientID %>");
            txtDOB.set_maxDate(new Date('2009/04/15'));

        }

The error I get is "Object doesn't support the property or method" on the set_maxDate line.


My aspx markup is

                    <telerik:RadDateInput ID="txtDOB" runat="server" DateFormat="dd/MM/yyyy">
                    </telerik:RadDateInput>

I am using Telerik Q2 2009 (2009.2.826.35)

Thanks

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 18 Nov 2009, 03:44 PM
Hello Andrew,

In order to access the client object you should use the $find shortcut method:
ASP.NET AJAX > Client Reference > Global Namespace > $find ...
function pageLoad()
{
   var txtDOB = $find("<%= txtDOB.ClientID %>");
   txtDOB.set_maxDate(new Date('2009/04/15'));
}

Kind regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andrew Currie
Top achievements
Rank 1
answered on 18 Nov 2009, 03:46 PM
Thanks

I have tried this but I then find that txtDOB variable is null.

Thanks again
0
Andrew Currie
Top achievements
Rank 1
answered on 18 Nov 2009, 03:54 PM
FYI I have also tried this in my markup

<ClientEvents OnFocus="SetMaxDate()" />

and then placed above code in a SetMaxDate() function but still txtDOB is null
0
Daniel
Telerik team
answered on 18 Nov 2009, 05:56 PM
Hello Andrew,

I updated my code-snippet to use the findControl (part of our static client-side library) method. Also you can find below a modified version of the "OnFocus" approach:
Telerik static client library

OnFocus approach:
<script type="text/javascript">
    function SetMaxDate(sender, args)
    {
        sender.set_maxDate(new Date('2009/04/15'));
    }
</script>
 
 
<telerik:RadDateInput ID="txtDOB" runat="server" DateFormat="dd/MM/yyyy">
    <ClientEvents OnFocus="SetMaxDate" />
</telerik:RadDateInput>

pageLoad approach:
<script type="text/javascript">
   function pageLoad()
   {
      var txtDOB = $telerik.findControl(document, "txtDOB");
      txtDOB.set_maxDate(new Date('2009/04/15'));
   }
</script>

I hope this helps.

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Input
Asked by
Andrew Currie
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Andrew Currie
Top achievements
Rank 1
Share this question
or