ios – Mobile Safari(10.3.1)DateTime-Local“输入有效值”错误

ios – Mobile Safari(10.3.1)DateTime-Local“输入有效值”错误,第1张

概述我在较新版本的iOS Mobile Safari上收到错误.在iOS 10.3版之前没有发生此错误.有人能指出我正确的方向吗? 这是原始HTML,附带的是检查视图和移动设备(iPhone 7)的视图. 简单解决! IOS要求在输入字段上设置值,其类型为“datetime-local”. 示例:< input type =“datetime-local”value =“2000-07-01T12:0 我在较新版本的iOS Mobile Safari上收到错误.在iOS 10.3版之前没有发生此错误.有人能指出我正确的方向吗?

这是原始HTML,附带的是检查视图和移动设备(iPhone 7)的视图.


解决方法 简单解决!

IOS要求在输入字段上设置值,其类型为“datetime-local”.

示例:< input type =“datetime-local”value =“2000-07-01T12:00”/>

而已 :)

我个人觉得将默认值设置为用户当前本地时间很好.这必须在没有秒的情况下在ISOTime中格式化,因此这可能是这样的代码:

// get the iso time string formatted for usage in an input['type="datetime-local"']var tzoffset = (new Date()).getTimezoneOffset() * 60000; //offset in millisecondsvar localiSOTime = (new Date(Date.Now() - tzoffset)).toISOString().slice(0,-1);var localiSOTimeWithoutSeconds = localiSOTime.slice(0,16);// select the "datetime-local" input to set the default value onvar dtlinput = document.querySelector('input[type="datetime-local"]');// set it and forget it ;)dtlinput.value = localiSOTime.slice(0,16);
总结

以上是内存溢出为你收集整理的ios – Mobile Safari(10.3.1)DateTime-Local“输入有效值”错误全部内容,希望文章能够帮你解决ios – Mobile Safari(10.3.1)DateTime-Local“输入有效值”错误所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1105603.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存