HTML5 Date Input Type Interfering with jQuery Datepicker

前端 未结 4 1479
孤街浪徒
孤街浪徒 2020-12-08 22:14

I am using the jQuery UI\'s datepicker for date selections on my site. One of my users just upgraded to the newest version of Chrome, which has built-in native date picker f

相关标签:
4条回答
  • 2020-12-08 22:41

    Add novalidate attribute to your form to remove browser's build-in validation.

    <form action="login.htm" novalidate>
    

    See this link for more info.

    0 讨论(0)
  • 2020-12-08 22:43

    Either switch from using input[type=date] to input[type=text] or use Modernizr to detect support for the native datepicker. I've wrote a post about the implications of both options here - http://tjvantoll.com/2012/06/30/creating-a-native-html5-datepicker-with-a-fallback-to-jquery-ui/.

    0 讨论(0)
  • 2020-12-08 22:45

    Use Modernizr or similar library to feature detect if the browser supports the input type=date, and then load the jQuery UI datepicker if if does not.

    if (!Modernizr.inputtypes.date) {
        $('input[type=date]').datepicker();
    }
    
    0 讨论(0)
  • 2020-12-08 22:52

    Sometimes you cannot modify form types. For example, I'm using Symfony2 Bundle's FormType.

    I had this problem using Genemu jQuery Datepicker, and I solved this problem adding a calendar image button and a litle of css code.

    You can see final result in this link

    Here you can read documentation for adding image icon: jQuery UI Datepicker

    Then, I simple added a css like this (maybe style rules will be different for you):

    form input[type=date] + img {
        position: relative;
        left: -25px;
    }
    
    0 讨论(0)
提交回复
热议问题