关于javascript的小问题求大神解答!!!

jiayoulee 2013-11-10 04:37:31
请问下面程序调试时为什么提示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">
 </td>
<td>
 </td>
</tr>
</table>
<br />
<br />
<br />
<div>

<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

</div>
</form>
</body>
</html>

...全文
475 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
pravity 2013-11-16
  • 打赏
  • 举报
回复
……把调用的地方全角()改半角()。
白鸽 2013-11-15
  • 打赏
  • 举报
回复
sswwyy 2013-11-15
  • 打赏
  • 举报
回复
-布谷鸟- 2013-11-15
  • 打赏
  • 举报
回复
ali_mushishi 2013-11-14
  • 打赏
  • 举报
回复
括号 那么明显。。。用我的二百五°的近视眼都看到了
leujunbao 2013-11-11
  • 打赏
  • 举报
回复
bdmh 2013-11-10
  • 打赏
  • 举报
回复
onchange="passHint(),这里是全角的括号,改成半角的
全栈极简 2013-11-10
  • 打赏
  • 举报
回复
另外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 = "";
            }
        }
全栈极简 2013-11-10
  • 打赏
  • 举报
回复
passHint(),这个括号是中文的。

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧