0
我遇到了問題,其中包含更新面板的表單上的字段,我想對其執行Jquery驗證。問題是當我點擊確定按鈕,驗證錯誤信息出現然後消失。看起來像一些後回型問題,但想知道是否有人可以提供幫助。代碼如下:Jquery驗證消息在更新面板中消失
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!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 id="Head1" runat="server">
<title>Project Management System</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$("#form1").validate({
rules: {
<%=txtFirstName.UniqueID %>: {
minlength: 5,
required: true
}
}, messages: {
<%=txtFirstName.UniqueID %>:{
required: "Please enter a valid username",
minlength: "Username must be atleast 3 characters"
}
}
});
});
</script>
<form id="form1" runat="server">
<div id="wrapper">
<div id="content">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:Label ID="lbFirstName" runat="server" Text="FirstName"></asp:Label>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
<asp:Button ID="btAddEmployee" runat="server" Text="Add"/>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</form>
</body>
</html>
jquery + updatepanels = - 毛 – Jason 2010-10-25 19:24:17