请问下面程序调试时为什么提示passHint()函数未定义?<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
       <script type = "text/javascript">
           function passHint() 
           {
               var txt = document.getElementById('txtPass').value;
               if (txt.length < 6) 
               {
                   document.all("tab").rows[0].cells[1].BgColor = "red";
                   document.all("tab").rows[0].cells[2].BgColor = "";
               }
               else 
               {
                   document.all("tab").rows[0].cells[2].BgColor = "red";
                   document.all("tab").rows[0].cells[1].BgColor = "";
               }
           }
       </script>
    <style type="text/css">
        .style1
        {
            width: 44%;
        }
        .style2
        {
            width: 316px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:TextBox ID="txtPass" runat="server" onchange="passHint()"></asp:TextBox>
    <br />
    <br />
    <br />
    <table id="tab" class="style1">
        <tr>
            <td class="style2">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
    <br />
    <br />
    <br />
    <div>
    
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    
    </div>
    </form>
</body>
</html>

解决方案 »

  1.   

    passHint(),这个括号是中文的。
      

  2.   

    另外js部分可以改为这样:
     function passHint() {
                var txt = document.getElementById('txtPass').value;
                if (txt.length < 6) {
                    document.all("tab").rows[0].cells[0].style.background = "red";
                    document.all("tab").rows[0].cells[1].style.background = "";
                }
                else {
                    document.all("tab").rows[0].cells[1].style.background = "red";
                    document.all("tab").rows[0].cells[0].style.background = "";
                }
            }
      

  3.   

    onchange="passHint(),这里是全角的括号,改成半角的