2

我正在使用 .net 4.0 和股票验证器在 VS2010 中创建一个 html5 站点。为了使验证器可访问,我在关联的文本框中添加了一个aria-labelledby,并在 aria-labelledby 值中设置了验证器 ID。验证器的 id 模式设置为静态。验证标签由 display:none css 样式隐藏,触发时将其删除。

似乎工作正常,因为NVDA看到错误消息并将其关联到正确的文本框。但是当我去验证它时,我收到以下错误:

aria-labelledby 属性必须指向同一文档中的元素

所以,问题是...... aria-labelledby可以引用一个不可见的控件吗?

4

1 回答 1

0

Quick answer is yes ... after some more testing I found out that NVDA will read the hidden span tag that is the validator error text.

The issue I was having was in making a required validator have its error message receivable by NVDA. Unfortunately the error is shown after the IsValid function is fired ... making the event fire after a postback. NVDA would see the page with the error messages, but not know that they were new.

To fix it I'm firing the validator on the blur event, as shown below.

I added a blur event to the control being validated, and called the validator attached to that control

onblur="validateControl(RequiredFieldValidatorID)"

The function called uses the ValidatorValidate function.

function validateControl(n) {
 ValidatorValidate(n);
}

This makes a required validator fire on blur. Still need to refocus on the control that has an error, but I think I'll need to catch the tab and redirect ... work in progress.

于 2013-05-29T17:46:17.587 回答