如下是我写的代码,为什么在使用了模板页的子页中用validate就不行呢,完全不起作用required: true也不提示必须输入,如下是代码,该怎么解决呢?麻烦大神指教。另外ContentPlaceHolder1_Button1 的ontentPlaceHolder1_前缀用的应该没错,点按钮后 alert("aswqdq");是有效果的,就是rules 不起作用
母页代码
<body>
<form id="form1" runat="server">
<div class="nav">
<table class="table" style="width: 100%; height: 165px;">
<tr>
<td rowspan="1" class="auto-style1">
<br />
<a href="">英雄列表</a></td>
<td rowspan="1" class="auto-style2">
<br />
<a href="">精美皮肤</a></td>
<td rowspan="1"colspan="2" rowspan="3" >
</td>
<td rowspan="1" class="auto-style3">
<br />
<a href="">符文天赋</a></td>
<td rowspan="1" class="auto-style4">
<br />
<a href="">关于我们</a></td>
</tr>
</table>
</div>
<div class="logo">
<a href="main.aspx"><img src="images/League_of_Legends_Logo_zh.png" style="height: 250px; width: 420px" /></a>
</div>
<div class="content">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
子页代码
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div style="height: 800px; background-color: #000000; opacity: 0.5; z-index: 1">
fe </div>
<div class="div6" style="background-color: transparent; border: 2px solid #FFFFFF; z-index: 3;">
<table class="regist" style="top: 121px; left: 114px; height: 439px; width: 700px; border:1px solid #FFFFFF;">
<tr>
<td colspan="3" class="auto-style9">
<pre> <span style="font-family:楷体; font-weight: bolder; font-size: xx-large;">英雄去战斗</span></pre>
</td>
</tr>
<tr>
<td rowspan="9" style="width:55%">
<div style="position:absolute; top: 6px; left: 5px; height: 422px; width: 264px;">
<img src="images/琴女.jpg" style="height: 422px; width: 259px" /></div>
</td>
<td class="auto-style5">账号:</td>
<td class="auto-style6"><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td class="auto-style5">密码:</td>
<td class="auto-style6"><asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox></td>
</tr>
<tr>
<td class="auto-style5">确认密码:</td>
<td class="auto-style6"><asp:TextBox ID="TextBox3" runat="server" TextMode="Password"></asp:TextBox></td>
</tr>
<tr>
<td class="auto-style5">昵称:</td>
<td class="auto-style6"><asp:TextBox ID="TextBox4" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td class="auto-style5">性别:</td>
<td class="auto-style6">
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="sex" Text="男" /> <asp:RadioButton ID="RadioButton2" runat="server" GroupName="sex" Text="女" /></td>
</tr>
<tr>
<td class="auto-style5">身份证:</td>
<td class="auto-style6"><asp:TextBox ID="TextBox5" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td class="auto-style5">电话:</td>
<td class="auto-style6"><asp:TextBox ID="TextBox6" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td class="auto-style5">邮箱:</td>
<td class="auto-style6"><asp:TextBox ID="TextBox7" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td class="auto-style8">
</td>
<td class="auto-style7">
<asp:Button ID="Button1" runat="server" Text="注册" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="重置" OnClick="Button2_Click" />
</td>
</tr>
</table>
</div>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/validate-1.9/jquery.validate.min.js" type="text/javascript"></script>
<script src="js/validate-1.9/jquery.validate.messages_cn.js" type="text/javascript"></script>
<script>
$(function () {
$("#ContentPlaceHolder1_Button1").click(function () {
$("#form1").validate({
rules: {
ContentPlaceHolder1_TextBox1 : { required: true, minlength: 1,maxlength:10 },
ContentPlaceHolder1_TextBox2 : { required: true, minlength: 5 },
ContentPlaceHolder1_TextBox3 : { required: true, minlength: 5 },
ContentPlaceHolder1_TextBox4 : { required: true, minlength: 5 },
ContentPlaceHolder1_TextBox5 : { required: true, minlength: 5 },
ContentPlaceHolder1_TextBox6 : { required: true, minlength: 5 },
ContentPlaceHolder1_TextBox7 : { required: true, minlength: 5 }
}
});
alert("aswqdq");
});
});
</script>
</asp:Content>