如何删除HTML5输入类型时间的秒数 [英] How to remove seconds of HTML5 input type time

查看:398
本文介绍了如何删除HTML5输入类型时间的秒数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Android和IOS开发HTML5应用程序,并遇到一些问题。
我想实现的是获得 HH:MM 格式< input type =time>

根据W3C
http://www.w3.org/TR/html5/forms.html#time-state-(type = time)



step 的默认属性为60秒。这意味着用户永远无法选择没有任何额外属性的秒数。IOS safari(IOS7 / 8)和Android(jellybeans - lolipop chrome latest)的时间选择按照预期工作。



问题是Chrome的输入显示 HH:MM:SS 而不是 HH:MM 。即使 SS 永远不会获得任何价值,但 00



有没有办法删除 SS 部分?



编辑
这个问题仅限于Android的Chrome浏览器。



JSfiddle: http:// jsfiddle.net/yymvLk9a/



提前致谢

解决方案

html

  < input id =foo/> 




 <$ (),$ b $(this).attr(type,text); 
});
$(#foo)。on(touchstart,function(){
$(this).attr(type,time);
});

将值显示为 type =text并在键盘显示之前更改类型。



简单但适用于我。



EDITED



我向google.and报告了此错误,并得到确认和修复。
此错误将在下次更新时消失。
https://code.google.com/p/铬/问题/细节?id = 459966


I'm developing HTML5 app for both Android and IOS and encountering some sort of buggy issue. What I want to achieve is to get HH:MM format of <input type="time">

According to W3C http://www.w3.org/TR/html5/forms.html#time-state-(type=time)

Default attribute of step is 60s. This means users would never be able to select seconds without any extra attributes and The timepickers of both IOS safari(IOS7/8) and Android(jellybeans - lolipop chrome latest) works as they are expected.

The problem is that Chrome's input displays HH:MM:SS instead of HH:MM. even though SS never get any value but 00

Is there any way to remove SS part?

Edit This issue is only on Android's Chrome.

JSfiddle : http://jsfiddle.net/yymvLk9a/

thanks in advance

解决方案

I got a solution for this.

html

<input id="foo" />

js

$("#foo").on("change",function(){
  $(this).attr("type","text");
});
$("#foo").on("touchstart",function(){
  $(this).attr("type","time");
});

display the value as type="text" and change the type before keyboard shows up.

simple but works great for me.

EDITED

I reported this bug to google.and got confirmed and fixed. This bug will be disappeared next update. https://code.google.com/p/chromium/issues/detail?id=459966

这篇关于如何删除HTML5输入类型时间的秒数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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