jquery datepicker not working in IE7 and IE8

10,750

First of all, just to be sure, don't use the same string for the id and the name property. And for God's sake, don't define your class with a reserved word like input, it's and internal class/element already. Go for something like pickerClass. Also, I think your jQuery selector syntax is wrong, no need for the input part, you already have an id for that element. This:

$("#dateTill").datepicker();

OR

$("input.pickerClass").datepicker();

if for some strange reason you want to select multiple inputs at once. Also, if you have a CSS defined class already then move the inline styling into the CSS if it's gonna be used for more input fields.

Share:
10,750
Richard Knop
Author by

Richard Knop

I'm a software engineer mostly working on backend from 2011. I have used various languages but has been mostly been writing Go code since 2014. In addition, I have been involved in lot of infra work and have experience with various public cloud platforms, Kubernetes, Terraform etc. For databases I have used lot of Postgres and MySQL but also Redis and other key value or document databases. Check some of my open source projects: https://github.com/RichardKnop/machinery https://github.com/RichardKnop/go-oauth2-server https://github.com/RichardKnop

Updated on June 04, 2022

Comments

  • Richard Knop
    Richard Knop almost 2 years

    This is my js:

    $(document).ready(function() {
     $("input#dateTill").datepicker();
    });
    

    My HTML:

    <input type="text" name="dateTill" id="dateTill" class="input" value="20.1.2011" maxlength="10" size="10" style="margin-left: 0; background: url(images/icons/16_calendar.png) 75px center no-repeat;" />
    

    The datepicker does work in all normal browsers like Firefox, Chrome, Opera. It does not work in IE7 and IE8.

    When I click inside the input field, the datepicker window does not appear.

    Any ideas? I am using jquery 1.4.4.

  • Richard Knop
    Richard Knop about 13 years
    @Dunhamzzz Of course, it has nothing to do with my problem. All of the issues listed by crowicked should have no effect on the datepicker functionality. They might be semantic or presentational mistakes/issues but they should not hve any effect on my problem.
  • crowicked
    crowicked about 13 years
    Have you tried what I suggested or just saying it shouldn't in advance? Yes, they probably SHOULDN'T have but we're talking IE here (yes, harsh again). Stick with good practices of coding and you'll avoid a lot of headache. I got to my conclusion by comparing your code with the sample code on jQuery UI dialog page (that works in IE8, already checked), I suggest you do the same. Debug suggestion: delete all your customization of the dialog and add one at a time to see where it breaks. Sorry if I sound cocky.
  • Dunhamzzz
    Dunhamzzz about 13 years
    Yeah you have to remember that IE can break everything over the most trivial matters, putting an extra comma at the end of an object property list is the worst one. Cleaning/Optimizing your code may very well fix any IE issues. Make sure the HTML is as valid as can be as well.