HTML 5 [input type = Date]控件,MAX日期在iPhone / Ipad中不起作用 [英] Html 5 [input type=Date] control, MAX date is not working in iPhone/Ipad

查看:727
本文介绍了HTML 5 [input type = Date]控件,MAX日期在iPhone / Ipad中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候。

使用html日期输入控件。

Working with html date input control.

输入type = date max = 2014-13-11

input type="date" max="2014-13-11"

在Chrome中识别 max'attribute因此限制并禁用了所有将来的日期

In chrome its recognizing 'max'attribute hence restricting and disabling all future date

但是,在iPad / iphone中同样无法使用。取而代之的是它允许在iPad中选择将来的日期。

But, the same is not working in iPad/iphone. Instead its allowing to select future date in iPad.

Googled知道ipad尚不支持日期控件的Max属性。

Googled and came to know that ipad is not yet supporting Max attribute of date control.

周围有什么解决方法吗?

Is there any work around? or any points / direction will be really help for me.

非常感谢。
Karthik

Many thanks. Karthik

推荐答案

iOS上的Safari不支持 max 分钟输入 input =日期

Safari on iOS does not support the attributes max and min for input="date".

为此,您可以使用 Pikaday 这样的JavaScript数据选择器。参见下面的演示:

You could use a JavaScript datapicker like Pikaday for this. See demo below:

var picker = new Pikaday({
  field: document.getElementById('datepicker'),
  firstDay: 1,
  minDate: new Date(), // minimum/earliest date
  maxDate: new Date(2017, 12, 31), // maximum/latest date
  yearRange: [2000, 2017],
  // demo only
  position: 'top left',
  reposition: false
});

<!-- Pikaday Library -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.5.1/css/pikaday.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.5.1/pikaday.min.js"></script>

<!-- Datepicker Input -->
<label for="datepicker">Date</label>
<input type="text" id="datepicker">

有关更多信息,请参见p租约请参阅GitHub上的文档

For more info, please refer to the documentation on GitHub.

这篇关于HTML 5 [input type = Date]控件,MAX日期在iPhone / Ipad中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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