0

While using Google Chrome, the function is working fine i.e all error messages are speaking out when button triggered as I given, but when using Internet Explorer or Firefox it starts validation from downside and that too one by one, but it is working fine with Google Chrome.

I have created two sample textboxes and given the required filed validator and assigned a function to speak error messages.

<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">&nbsp;</td>
                <td>
                    <asp:Button ID="Button1" runat="server" Text="Submit" OnClientClick="perform();"/>
                </td>
            </tr>

It should work fine with Internet Explorer, that is, all error messages should be spoke at the same time or at least validate from upside to down.

sai kumar
  • 1
  • 5
  • can you try `else if (password == '') {` here? seems invalid to show all messages at once – Just code Jan 22 '19 at 04:48
  • Thank you..@Justcode That's working if we are validating only 2 texboxes but I need to figure out exact way of giving conditions if there are many texboxes to validate... "yes its not showing all error message at a time in IE" – sai kumar Jan 22 '19 at 11:31
  • so, you should consider creating ifelse for all the controls – Just code Jan 22 '19 at 12:32

0 Answers0