5
是否可以检测浏览器是否支持input type="date"
与placeholder
?检测输入类型=“日期”是否支持占位符
是否可以检测浏览器是否支持input type="date"
与placeholder
?检测输入类型=“日期”是否支持占位符
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);
http://modernizr.com /文档/#inputtypes – j08691