热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在谷歌浏览器中禁用本机datepicker-DisablenativedatepickerinGoogleChrome

DatepickerlandedonChrome20,isthereanyattributetodisableit?MyentiresystemusesjQuery

Date picker landed on Chrome 20, is there any attribute to disable it? My entire system uses jQuery UI datepicker and it's crossbrowser, so, I want to disable Chrome native datepicker. Is there any tag attribute?

日期选择器登陆Chrome 20,有什么属性可以禁用它吗?我的整个系统使用jQuery UI datepicker,它是跨浏览器,所以,我想禁用Chrome本机datepicker。有标签属性吗?

11 个解决方案

#1


124  

To hide the arrow:

隐藏箭头:

input::-webkit-calendar-picker-indicator{
    display: none;
}

And to hide the prompt:

并隐藏提示:

input[type="date"]::-webkit-input-placeholder{ 
    visibility: hidden !important;
}

#2


44  

If you have misused you can probably use:

如果您误用了,您可以使用:

$('input[type="date"]').attr('type','text');

after they have loaded to turn them into text inputs. You'll need to attach your custom datepicker first:

在加载后将它们转换为文本输入。您需要先附上您的自定义数据表:

$('input[type="date"]').datepicker().attr('type','text');

Or you could give them a class:

或者你可以给他们上一堂课:

$('input[type="date"]').addClass('date').attr('type','text');

#3


15  

You could use:

您可以使用:

jQuery('input[type="date"]').live('click', function(e) {e.preventDefault();}).datepicker();

#4


7  

With Modernizr (http://modernizr.com/), it can check for that functionality. Then you can tie it to the boolean it returns:

使用Modernizr (http://modernizr.com/),它可以检查这个功能。然后你可以将它绑定到它返回的布尔值:

// does not trigger in Chrome, as the date Modernizr detects the date functionality.
if (!Modernizr.inputtypes.date) { 
    $("#opp-date").datepicker();
}

#5


4  

This worked for me

这为我工作

input[type=date]::-webkit-inner-spin-button, 
input[type=date]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}

#6


2  

The code above doesn't set the value of the input element nor does it fire a change event. The code below works in Chrome and Firefox (not tested in other browsers):

上面的代码没有设置输入元素的值,也没有触发更改事件。下面的代码在Chrome和Firefox中运行(在其他浏览器中没有测试):

$('input[type="date"]').click(function(e){
     e.preventDefault();
}).datepicker({
    onSelect: function(dateText){
        var d = new Date(dateText),
        dv = d.getFullYear().toString().pad(4)+'-'+(d.getMonth()+1).toString().pad(2)+'-'+d.getDate().toString().pad(2);
        $(this).val(dv).trigger('change');
    }
});

pad is a simple custom String method to pad strings with zeros (required)

pad是一个简单的自定义字符串方法,可以用0 (required)填充字符串

#7


1  

I agree with Robertc, the best way is not to use type=date but my JQuery Mobile Datepicker plugin uses it. So I have to make some changes:

我同意Robertc的观点,最好的方法不是使用type=date,但是我的JQuery移动Datepicker插件使用它。所以我必须做出一些改变

I'm using jquery.ui.datepicker.mobile.js and made this changes:

我用jquery.ui.datepicker.mobile。并做了如下修改:

From (line 51)

从(51)行

$( "input[type='date'], input:jqmData(type='date')" ).each(function(){

to

$( "input[plug='date'], input:jqmData(plug='date')" ).each(function(){

and in the form use, type text and add the var plug:

在表单使用中,输入文本并添加var plug:


#8


1  

I use the following (coffeescript):

我使用以下(coffeescript):

$ ->
  # disable chrome's html5 datepicker
  for datefield in $('input[data-datepicker=true]')
    $(datefield).attr('type', 'text')
  # enable custom datepicker
  $('input[data-datepicker=true]').datepicker()

which gets converted to plain Javascript:

将其转换为普通Javascript:

(function() {
  $(function() {
    var datefield, _i, _len, _ref;
    _ref = $('input[data-datepicker=true]');
    for (_i = 0, _len = _ref.length; _i <_len; _i++) {
      datefield = _ref[_i];
      $(datefield).attr('type', 'text');
    }
    return $('input[data-datepicker=true]').datepicker();
  }); 
}).call(this);

#9


0  

This works for me:

这工作对我来说:

;
(function ($) {
    $(document).ready(function (event) {
        $(document).on('click input', 'input[type="date"], input[type="text"].date-picker', function (e) {
            var $this = $(this);
            $this.prop('type', 'text').datepicker({
                showOtherMonths: true,
                selectOtherMonths: true,
                showButtonPanel: true,
                changeMonth: true,
                changeYear: true,
                dateFormat: 'yy-mm-dd',
                showWeek: true,
                firstDay: 1
            });

            setTimeout(function() {
                $this.datepicker('show');
            }, 1);
        });
    });
})(jQuery, jQuery.ui);

See also:

参见:

How can I disable the new Chrome HTML5 date input?

如何禁用新的Chrome HTML5日期输入?

http://zizhujy.com/blog/post/2014/09/18/Add-date-picker-to-dynamically-generated-input-elements.aspx

http://zizhujy.com/blog/post/2014/09/18/Add-date-picker-to-dynamically-generated-input-elements.aspx

#10


0  

I know this is an old question now, but I just landed here looking for information about this so somebody else might too.

我知道这是一个老问题,但我只是来这里寻找有关这个问题的信息,这样其他人也可能。

You can use Modernizr to detect whether the browser supports HTML5 input types, like 'date'. If it does, those controls will use the native behaviour to display things like datepickers. If it doesn't, you can specify what script should be used to display your own datepicker. Works well for me!

您可以使用Modernizr来检测浏览器是否支持HTML5输入类型,比如'date'。如果是的话,这些控件将使用本机行为来显示数据表之类的东西。如果没有,可以指定应该使用哪个脚本显示自己的datepicker。适用于我!

I added jquery-ui and Modernizr to my page, then added this code:

我在页面中添加了jquery-ui和Modernizr,然后添加了以下代码:


This means that the native datepicker is displayed in Chrome, and the jquery-ui one is displayed in IE.

这意味着本地datepicker会在Chrome中显示,而jquery-ui则会在IE中显示。

#11


0  

For Laravel5 Since one uses

对于Laravel5,因为有一个词

{!! Form::input('date', 'date_start', null , ['class' => 'form-control', 'id' => 'date_start', 'name' => 'date_start']) !!}

{ ! !形式::输入(‘日期’,‘date_start’,null,[“类”= >“表单控件”,“id”= >“date_start”,'名字' = > ' date_start '])! ! }

=> Chrome will force its datepicker. => if you take it away with css you will get the usual formatting errors!! (The specified value does not conform to the required format, "yyyy-MM-dd".)

=> Chrome将强制其datepicker。=>如果你用css把它去掉,你会得到通常的格式错误!(指定的值不符合所要求的格式,“yyyy-MM-dd”)。

SOLUTION:

解决方案:

$('input[type="date"]').attr('type','text');

$('输入(type = "日期")).attr(“类型”、“文本”);

$("#date_start").datepicker({
    autoclose: true,
    todayHighlight: true,
    dateFormat: 'dd/mm/yy',
    changeMonth: true,
    changeYear: true,
    viewMode: 'months'
});
$("#date_stop").datepicker({
    autoclose: true,
    todayHighlight: true,
    dateFormat: 'dd/mm/yy',
    changeMonth: true,
    changeYear: true,
    viewMode: 'months'
});
$( "#date_start" ).datepicker().datepicker("setDate", "1d");
$( "#date_stop" ).datepicker().datepicker("setDate", '2d');

推荐阅读
  • 前言--页数多了以后需要指定到某一页(只做了功能,样式没有细调)html ... [详细]
  • 1.如何在运行状态查看源代码?查看函数的源代码,我们通常会使用IDE来完成。比如在PyCharm中,你可以Ctrl+鼠标点击进入函数的源代码。那如果没有IDE呢?当我们想使用一个函 ... [详细]
  • 使用JS、HTML5和C3创建自定义弹出窗口
    本文介绍如何结合JavaScript、HTML5和C3.js来实现一个功能丰富的自定义弹出窗口。通过具体的代码示例,详细讲解了实现过程中的关键步骤和技术要点。 ... [详细]
  • 使用Bootstrap创建响应式渐变固定头部导航栏的方法
    本文详细介绍了如何利用Bootstrap框架构建一个具有渐变效果的固定顶部响应式导航栏,包括HTML结构、CSS样式以及JavaScript交互的完整实现过程。适合前端开发者和学习者参考。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • 一个登陆界面
    预览截图html部分123456789101112用户登入1314邮箱名称邮箱为空15密码密码为空16登 ... [详细]
  • Vue 3.0 翻牌数字组件使用指南
    本文详细介绍了如何在 Vue 3.0 中使用翻牌数字组件,包括其基本设置和高级配置,旨在帮助开发者快速掌握并应用这一动态视觉效果。 ... [详细]
  • 开发笔记:小程序分类页实现三级分类,顶部导航栏,左侧分类栏,右侧数据列表
    开发笔记:小程序分类页实现三级分类,顶部导航栏,左侧分类栏,右侧数据列表 ... [详细]
  • HTML5实现逼真树叶飘落动画详解
    本文详细介绍了如何利用HTML5技术创建一个逼真的树叶飘落动画,包括HTML、CSS和JavaScript的代码实现及优化技巧。 ... [详细]
  • 前端技术分享——利用Canvas绘制鼠标轨迹
    作为一名前端开发者,我已经积累了Vue、React、正则表达式、算法以及小程序等方面的技能,但Canvas一直是我的盲区。因此,我在2018年为自己设定了一个新的学习目标:掌握Canvas,特别是如何使用它来创建CSS3难以实现的动态效果。 ... [详细]
  • Explore how Matterverse is redefining the metaverse experience, creating immersive and meaningful virtual environments that foster genuine connections and economic opportunities. ... [详细]
  • 技术分享:从动态网站提取站点密钥的解决方案
    本文探讨了如何从动态网站中提取站点密钥,特别是针对验证码(reCAPTCHA)的处理方法。通过结合Selenium和requests库,提供了详细的代码示例和优化建议。 ... [详细]
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • 本文详细介绍如何使用CSS自定义HTML5视频播放器的样式,涵盖常见属性及跨浏览器兼容性问题。发布时间:2020-09-14 14:46:29;来源:亿速云;阅读量:58;作者:小新。 ... [详细]
  • 本文详细介绍了如何使用 HTML 和 CSS 对文件上传按钮进行样式美化,使用户界面更加友好和美观。 ... [详细]
author-avatar
执子之手2502891083
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有