Question

Why is the following giving me an error in IE8? It works fine in Chrome:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.10.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>

<script type="text/javascript" language="javascript">

    $(document).ready(function() {

        $("#txtDate").datepicker({
            changeMonth: true,
            changeYear: true,
            yearRange: "+0:+1",
            showButtonPanel: false,
            dateFormat: "dd/mm/yy",
            showOn: "button",
            buttonImage: "../../images/Calendar.png",
            buttonImageOnly: true
        });

    });

</script>

So absolutely no issues with this in Chrome, but IE8 gives me the following error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; chromeframe/27.0.1453.110; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.0.3705; InfoPath.1; .NET4.0C; .NET4.0E)
Timestamp: Wed, 12 Jun 2013 15:18:48 UTC

Message: 'length' is null or not an object
Line: 139
Char: 17
Code: 0
URI: http://intranet/aspnet_client/system_web/1_1_4322/WebUIValidation.js

The datepicker still works though, it popsup when I click the icon, I can select a date and the date appears in the textbox. But when I click the date, the datepicker is supposed to disappear, but it doesn't, instead it displays the above error.

Any ideas?

Was it helpful?

Solution

Apparently a bug in jQuery. I just added a do nothing event handler to "onSelect" event of the jQuery datepicker and it worked fine. Below is the modified jQuery code:

$(document).ready(function () {
    $("#txtDate").datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: "+0:+1",
        showButtonPanel: false,
        dateFormat: "dd/mm/yy",
        showOn: "button",
        buttonImage: "../../images/Calendar.png",
        buttonImageOnly: true,
        onSelect: function () { }
    });

});

I was getting the error in IE 10 as well. Let me know if it works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top