Html 5 datepicker in firefox

后端 未结 5 1155
独厮守ぢ
独厮守ぢ 2021-02-04 05:58

Is there any way that I can set enable a datepicker in firefox(version 21) with HTML 5. I dont want to use a jQuery based datepicker because javascript will be disabled in the b

5条回答
  •  野的像风
    2021-02-04 06:04

    jQuery UI has a datepicker widget that you can conditionally load if the browser doesn't have one built in. The catch is that even if you only select the datepicker widget in a custom jQuery UI build, it's still a significant download.

    My favorite solution is to use yepnope, which comes with Modernizr, to conditionally load the jQuery UI CSS and JS files only if needed for the datepicker. By combining this with an optimized build of Modernizr and a datepicker-only jQuery UI build, it gives you the smallest download for all possible browsers.

    yepnope({ /* included with Modernizr */
      test : Modernizr.inputtypes.date,
      nope : {
        'css': '/path-to-your-css/jquery-ui-1.10.3.custom.min.css',
        'js': '/path-to-your-js/jquery-ui-1.10.3.datepicker.min.js'
      },
      callback: { // executed once files are loaded
        'js': function() { $('input[type=date]').datepicker({dateFormat: "yy-mm-dd"}); } // default HTML5 format
      }
    });
    

提交回复
热议问题