最简单的 javascript 函数不触发
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="jQueryValidation.Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="Scripts/jquery-1.6.1.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function checkValidity() {
var container = document.getElementById("toggle");
alert("uspeh!");
var inputArray = container.getElementsByTagName("input");
}
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="toggle">
<asp:Label ID="lblName" runat="server" Text="Vnesi ime: "></asp:Label>
<span><asp:TextBox ID="txtName" runat="server" data-errormessage="Внесете име" data-class="required"></asp:TextBox></span>
<br />
<asp:Label ID="lblSurname" runat="server" Text="Vnesi prezime: "></asp:Label>
<span><asp:TextBox ID="txtSurname" runat="server" data-errormessage="Внесете презиме" data-class="required"></asp:TextBox></span>
<br />
<asp:Label ID="lblNickname" runat="server" Text="Vnesi nadimak: "></asp:Label>
<span><asp:TextBox ID="txtNickname" runat="server" data-errormessage="Внесете надимак" data-class="required"></asp:TextBox></span>
<br /><br />
<asp:Button ID="btnSend" runat="server" Text="Send"
OnClientClick="checkValidity(); return false;" onclick="btnSend_Click" />
</div>
</form>
</body>
</html>
已更新。
我不知道为什么没有弹出窗口出现。有什么想法吗?提前致谢!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="jQueryValidation.Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="Scripts/jquery-1.6.1.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function checkValidity() {
var container = document.getElementById("toggle");
alert("uspeh!");
var inputArray = container.getElementsByTagName("input");
}
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="toggle">
<asp:Label ID="lblName" runat="server" Text="Vnesi ime: "></asp:Label>
<span><asp:TextBox ID="txtName" runat="server" data-errormessage="Внесете име" data-class="required"></asp:TextBox></span>
<br />
<asp:Label ID="lblSurname" runat="server" Text="Vnesi prezime: "></asp:Label>
<span><asp:TextBox ID="txtSurname" runat="server" data-errormessage="Внесете презиме" data-class="required"></asp:TextBox></span>
<br />
<asp:Label ID="lblNickname" runat="server" Text="Vnesi nadimak: "></asp:Label>
<span><asp:TextBox ID="txtNickname" runat="server" data-errormessage="Внесете надимак" data-class="required"></asp:TextBox></span>
<br /><br />
<asp:Button ID="btnSend" runat="server" Text="Send"
OnClientClick="checkValidity(); return false;" onclick="btnSend_Click" />
</div>
</form>
</body>
</html>
Updated.
I have no idea why no pop-up shows up. Any idea? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
通过这样做
您声明一个全局作用域的函数。在浏览器上下文中,这与执行以下操作相同:
Try
By doing
You declare a function to the global scope. In the context of a browser it is the same as doing: