HTML5日期输入类型干扰jQuery Datepicker [英] HTML5 Date Input Type Interfering with jQuery Datepicker

查看:109
本文介绍了HTML5日期输入类型干扰jQuery Datepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上使用jQuery UI的datepicker作日期选择。我的一位用户刚刚升级到最新版本的Chrome,它内置了HTML5的原生日期选择器。两个用户界面相互重叠是一个大问题。另一个问题是当用户提交日期时,数据库中的日期恢复为0000-00-00,并且产生了错误的数据。



如果我删除了jQuery datepicker,大多数没有使用最新浏览器的用户都没有弹出日期选择器。而且,拥有最新浏览器的用户将会有两个重叠的日历,这会打破应用程序。我的问题是如何禁用最新的浏览器显示内置的日期函数,并继续使用jQuery Datepicker?

解决方案

p>使用 Modernizr 或类似的库来检测浏览器是否支持 input type = date ,然后加载jQuery UI日期选择器,如果没有。

  if(!Modernizr.inputtypes。 date){
$('input [type = date]')。datepicker();
}


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 for HTML5. The big problem as the two UIs overlap each other. The other problem is when the user submits a date, the date in database reverts to "0000-00-00" and is producing bad data.

If I remove the jQuery datepicker, most of the users not using the latest-greatest browsers will not have a popup date picker. And, those who have the newest browser will have two overlapping calendars which breaks the application. My question is how do I disable the newest browsers from displaying the built-in date function and just continue to use the jQuery Datepicker?

解决方案

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();
}

这篇关于HTML5日期输入类型干扰jQuery Datepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆