2012-04-30 72 views

回答

7

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);