2016-11-06 12 views
0

試圖驗證上https://validator.w3.org/nu/#fileNu HTML Checker的驗證錯誤:「元素輸入上屬性類型的值錯誤收音機」。

<fieldset> 
<p class="city" id="citypref">Generally, I would prefer to live in...</p> 
<br> 
<label for="la" id="laLabel"> 
<br> 
<input type="radio" name="city" id="la" value="la" aria-required="false" aria-labelledby="laLabel" role="radiogroup" >Los Angeles, California</label> 
<br> 
<label for="boston" id="bostonLabel"> 
<input type="radio" name="city" id="boston" value="boston" aria-required="false" aria-labelledby="bostonLabel" role="radiogroup" >Boston, Massachusetts</label> 
<br> 
<label for="both" id="bothLabel"> 
<input type="radio" name="city" id="both" value="both" aria-required="false" aria-labelledby="bothLabel" role="radiogroup" >Both</label> 
<br> 
<label for="neither" id="neitherLabel"> 
<input type="radio" name="city" id="neither" value="neither" aria-required="false" aria-labelledby="neitherLabel" role="radiogroup" >Neither</label> 
<br> 
</fieldset> 

任何提示以下HTML,當我得到這個錯誤

Error: Bad value radio for attribute type on element input.

回答

0

似乎https://validator.w3.org/尚未配備以下代碼:

aria-required="false" 
aria-labelledby="neitherLabel" 
role="radiogroup" 

只要你刪除它們,你的代碼將通過沒有任何問題。

W3網站提供了關於如何使用此頁上的前3個代碼的示例:https://www.w3.org/TR/WCAG20-TECHS/ARIA2.html。 這是他們所提供的一個例子:

<form action="#" method="post" id="alerts1"> 
<label for="acctnum" data-required="true">Account Number</label> 
<input size="12" type="text" id="acctnum" 
    aria-required="true" name="acctnum" /> 

<p id="radio_label" data-required="true">Please send an alert when balance exceeds $3,000.</p> 

<ul id="rg" role="radiogroup" aria-required="true" aria-labelledby="radio_label"> 
<li id="rb1" role="radio">Yes</li> 
<li id="rb2" role="radio">No</li> 
</ul> 
</form> 

當我複製自己example並粘貼在他們的驗證,它未能通過,並給我您收到同樣的錯誤消息。

因此,我建議直接聯繫他們,要求他們將以前的3個代碼作爲有效用法添加到他們的驗證器數據庫中。

更新:

退房史蒂夫的回答澄清。

+0

@sideshowbarker感謝您的反饋意見,怎麼樣'ul'和'li'標籤?驗證器在我的實驗中似乎不接受它。 – Ibrahim

+0

請參閱史蒂夫的修訂答案:ARIA in HTML [禁止'role =「radiogroup」'爲'ul'](https://www.w3.org/TR/html-aria/#ul)和[禁止'role =「無線電「'爲'li'](https://www.w3.org/TR/html-aria/#li)。因此[WCAG 2.0 *技術*中的示例](https://www.w3.org/TR/WCAG20-TECHS/ARIA2.html#ARIA2-ex3)是錯誤的 - 這是* Techniques for WCAG 2.0 * doc。關於在HTML中使用ARIA的唯一規範(正式/官方)規則來源是實際的[ARIA in HTML](https://www.w3.org/TR/html-aria)規範。其他地方的任何示例都應該根據該規範中的規則進行檢查。 – sideshowbarker

5

It seems that https://validator.w3.org/ is not yet equipped with the following codes

它實現在https://www.w3.org/TR/html-aria/其中prohibits role=radiogroup on input type="radio"定義的用於HTML使用ARIA的一致性要求。它定義了所有元素的有效角色值。沒有input元素允許role="radio"input type="radio"只允許role="menuitemradio"

另一個回答錯誤地建議ul role="radiogroup"li role="radio"。但在HTML prohibits role="radiogroup" for ulprohibits role="radio" for li ARIA。

請注意,在ARIA 1.1中引入了驗證器無法識別的一些角色和屬性屬性。這正在進行中。

如果你有一個問題與W3C驗證建議filing an issue

相關問題