【问题标题】:Detect if input type="date" supports placeholder检测输入类型=“日期”是否支持占位符
【发布时间】:2012-04-30 16:42:27
【问题描述】:

是否可以检测浏览器是否支持input type="date"placeholder

【问题讨论】:

标签: javascript jquery html modernizr


【解决方案1】:

W3 验证器说占位符属性在日期输入上无效。验证此 HTML:

<!doctype html>
<title>date placeholder test</title>
<input type="date"  placeholder="enter a date">

给出错误:“Attribute placeholder not allowed on element input at this point.”...并说您可以使用属性“placeholder when type is text, search, url, tel, e-mail, password, or number”。

此外,Chrome 不会显示日期输入的占位符,即使它认为 JS 中存在该属性(这大致是 Modernizr 检查属性的方式):

var test = document.createElement(element);
test.type = 'date';
alert('placeholder' in test);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-06
    • 2016-05-24
    • 2012-03-26
    • 2013-06-30
    • 2021-02-03
    • 1970-01-01
    • 2017-04-15
    相关资源
    最近更新 更多