2012-04-30 70 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);