当您尝试在表单顶部放置标题和免责声明(如“所有字段都是必需的,除非标记为可选”)时,我不确定表单是如何使用 aria-labelledby 或 aria- describeby 的。我认为这就是我认为的完成方式,但我是可访问性的新手,所以任何更正将不胜感激!
<form id="profile optional">
<h1 arialabelledby="profile">Profile</h1>
<p aria-describedby="optional">All fields are required unless marked optional</p>
<fieldset>
<legend id="userInfo" aria-labelledby="formA">User Info</legend>
<div class="form-control">
<label id="firstName" for="firstName">First Name</label>
<input type="text" name="firstName" aria-labelledby="firstName userInfo" aria-required="true" aria-describedby="error-message"/>
<span id="error-message" style="display:none" aria-hidden="true">Name is required</span>
</div>
<div class="form-control">
<label id="lastName" for="lastName">Last Name</label>
<input type="text" name="lastName" aria-labelledby="lastName userInfo" aria-required="true" aria-describedby="error-message"/>
<span id="error-message" style="display:none" aria-hidden="true">Name is required</span>
</div>
<div class="form-control">
<label id="nickName" for="nickName">Nick Name (optional)</label>
<input type="text" name="nickName" aria-labelledby="nickName userInfo"/>
</div>
<fieldset>
<fieldset>
...
</fieldset>
<button type="submit" aria-label="Submit Profile">Submit</button>
</form>
编辑*提交按钮的代码