在使用谷歌浏览器时,该功能运行良好,即当我给出的按钮触发时,所有错误消息都会发出,但是当使用 Internet Explorer 或 Firefox 时,它会从缺点开始验证,而且也是一一验证,但它与谷歌一起工作正常铬合金。
我创建了两个示例文本框,并给出了所需的归档验证器,并分配了一个函数来说出错误消息。
<script src="https://code.responsivevoice.org/responsivevoice.js"></script>
<script>
function perform() {
if (document.getElementById('user').style.display == "inline") {
responsiveVoice.speak("" + document.getElementById('user').innerHTML + "");
}
if (document.getElementById('pass').style.display == "inline") {
responsiveVoice.speak("" + document.getElementById('pass').innerHTML + "");
}
}
</script>
<body>
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td class="auto-style2">Username</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="user" runat="server" ControlToValidate="TextBox1" ErrorMessage="Enter Username" Display="Dynamic" ForeColor="#FF3300"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">Password</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="pass" runat="server" ControlToValidate="TextBox2" ErrorMessage="enter password" Display="Dynamic" ForeColor="#FF3300"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td>
<asp:Button ID="Button1" runat="server" Text="Submit" OnClientClick="perform();"/>
</td>
</tr>
它应该可以在 Internet Explorer 上正常工作,也就是说,所有错误消息都应该同时发出,或者至少从上到下进行验证。