日期输入在 Firefox 中不起作用 [英] Date input not working in firefox

查看:45
本文介绍了日期输入在 Firefox 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下日期输入:

<label for="start_date">开始日期</label><input type="date" class="form-control" name="start_date" id="start_date" placeholder="mm/dd/yyyy">

如果我在 chrome 中点击它,会弹出一个日期选择器:

但是,如果我在 Firefox 中单击它,日期选择器不会弹出 up:

有谁知道为什么会发生这种情况和/或我如何在 Firefox 中修复它以使其保持一致?

注意 - 我正在使用引导程序 3

提前致谢!!

解决方案

很遗憾 在 firefox 中不受支持.为了能够在所有浏览器中使用日期类型,您可以使用 Modernizer 进行检查,如果不支持,您可以回退到使用 javascript 来显示 datepickerr.

I have the following date input:

<div class="form-group">
    <label for="start_date">Start Date</label>
    <input type="date" class="form-control" name="start_date" id="start_date" placeholder="mm/dd/yyyy">
</div>

If I click on it in chrome, a date picker pops up:

However, if I click it in firefox, the datepicker does not pop up:

Does anyone know why this is happening and/or how I can fix it in firefox so it is consistent?

Note - I am using bootstrap 3

Thanks in advance!!

解决方案

Unfortunately <input type="date"/> is not supported in firefox. To be able to use date type in all browser you can check using modernizer and if not supported you can fall back to use javascript to show the datepickerr.

<script>
    $(function(){           
        if (!Modernizr.inputtypes.date) {
            $('input[type=date]').datepicker({
                  dateFormat : 'yy-mm-dd'
                }
             );
        }
    });
</script>

这篇关于日期输入在 Firefox 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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