Ravichandra
Ravichandra

Reputation: 1270

jQuery(" ").datepicker({ }) is not working in IE7/8

My code is

    jQuery(function() {
        jQuery("#fromDatepicker").datepicker({
            changeMonth : true,
            changeYear : true,
            dateFormat: 'mm/dd/yy'
        });
    });
    jQuery(function() {
        jQuery("#toDatepicker").datepicker({
            changeMonth : true,
            changeYear : true,
            dateFormat: 'mm/dd/yy'
        });
    });

and input fields are

<input type="text" id="fromDatepicker" name="searchStartDate"  size="20">
<input type="text" id="fromDatepicker" name="searchStartDate"  size="20">

the calender is displaying but,

when I select a date on the calendar, the date is not selecting and not entering the date into the text field.

i am using

  1. jquery-1.6.2.js
  2. jquery-1.6.2.min.js
  3. jquery.ui.core.js
  4. jquery.ui.datepicker.js
  5. jquery.ui.datepicker.css

Upvotes: 0

Views: 1619

Answers (2)

Mark Schultheiss
Mark Schultheiss

Reputation: 34168

You can simplify this entire thing a bit:

<input type="text" id="fromDatepicker"  size="20" />
<input type="text" id="toDatepicker"  size="20" /> 


jQuery(function() {
    jQuery("#fromDatepicker, #toDatepicker").datepicker({
        changeMonth: true,
        changeYear: true,
        dateFormat: 'mm/dd/yy'
    });
});

See it in action here: http://jsfiddle.net/MarkSchultheiss/jUsTr/

By putting the comma between the selectors they are two selectors.

Upvotes: 0

Dunhamzzz
Dunhamzzz

Reputation: 14798

You are including the same version of jQuery twice, jquery-1.6.2.js and jquery-1.6.2.min.js. Just load the latter and this should stop some of the issues you are having.

Additionally, you have unnecessarily put the code into 2 jQuery(); calls, they could be put into one like this

jQuery(function() {
    jQuery("#fromDatepicker").datepicker({
        changeMonth : true,
        changeYear : true,
        dateFormat: 'mm/dd/yy'
    });

    jQuery("#toDatepicker").datepicker({
        changeMonth : true,
        changeYear : true,
        dateFormat: 'mm/dd/yy'
    });
});

Upvotes: 1

Related Questions