Hey,
I am having an issue where i have fields on a form that contains an update panel that i want to do Jquery validation on. The issue is when i click the OK button, the validation error message appears then goes away. Looks like some post back type of issue but was wondering if someone could help. THe code is below:
<%@ 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>