Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date picker html5 tag is not working on Mozilla, IE browsers. But its working only on Chrome

I am trying to use HTML 5 Date picker tag in my website. But this tag is not supporting on Mozilla & IE. Can you please share me any hack to work this code in IE and Mozilla.

I want to use only HTML5. i don't want to go for JavaScript.

like image 617
user3801514 Avatar asked Jul 03 '14 11:07

user3801514


2 Answers

Date is only supported in Chrome, Opera, Safari and Android Browser 4.4+

http://beta.caniuse.com/#search=date

like image 138
Tom Maton Avatar answered Nov 02 '22 15:11

Tom Maton


You can user jQuery date picker in case of Mozilla: Check the browser using $.browser.mozilla but it will not work in jQuery>1.9, so you have to use jQuery Migration as shown below:

     <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
      <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>//jQuery migration
    <script>
        if ($.browser.mozilla)
    {
        if ($('.datepicker')[0].type != 'date') $('.datepicker').datepicker();
        $(function () {
            $(".datepicker").datepicker({
                changeMonth: true,
                changeYear: true,
                yearRange: "1900:2015",
                dateFormat: "yy-mm-dd",
                defaultDate: '1900-01-01'
            });
        });
    }

</script>
like image 2
Harmeet Singh Avatar answered Nov 02 '22 14:11

Harmeet Singh