Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Date Picker not working on Chrome

Tags:

jquery-ui

I've a jQuery UI Calendar as below and it works on IE only not on Chrome:

<input type="image" src="/images/caleder.jpg" id="btnCalendar" />

<script type="text/javascript">
$(function () {
    $("#btnPeriodCal").datepicker();
});
</script>

If I change type="text" it seems to work. Could someone please help me with how to resolve the above issue. I can't use type="text" as I need to show the image.

Thanks.

like image 635
Nil Pun Avatar asked Jun 07 '12 13:06

Nil Pun


3 Answers

I have a sample problem with date picker.

I used date picker and it worked fine in Firefox and IE but not in chrome. I can see the calender when I click the input field. I selected the date but the date values are not entering in input field.

I don't have option so I changed type='text' then it works in chrome..

Input type is date

Input type is text

like image 169
Mahesh V Avatar answered Nov 02 '22 04:11

Mahesh V


You can use a handler:

<script>
$(function() {
    $( "#datepicker" ).datepicker({
        showOn: "button",
        buttonImage: "images/calendar.gif",
        buttonImageOnly: true
    });
});
</script>

Hope this works! :)

like image 34
Praveen Kumar Purushothaman Avatar answered Nov 02 '22 06:11

Praveen Kumar Purushothaman


I had the same problem. And I thought why input could work, but button could not. The trick is that input gets focus when clicked, button doesn't. Try this:

$(function () {
    $("#btnPeriodCal").datepicker().click(function () { $(this).focus(); });
});
like image 1
Xavier Liao Avatar answered Nov 02 '22 04:11

Xavier Liao