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:
ajitbhatti
Member
2 Points
6 Posts
Jquery validate message disappearing in update panel
Oct 25, 2010 03:50 PM|LINK
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=">
<script type="text/javascript" src=">
</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:Table ID="Table1" runat="server">
<asp:TableRow Height="30">
<asp:TableCell Width="50">
<asp:Label ID="lbFirstName" runat="server" Text="FirstName"></asp:Label>
</asp:TableCell>
<asp:TableCell Width="200">
<asp:label></asp:label>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Width="20">
<asp:Button ID="btAddEmployee" runat="server" Text="Add"/>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</form>
</body>
</html>
medelbrock
Member
659 Points
149 Posts
Re: Jquery validate message disappearing in update panel
Oct 25, 2010 08:08 PM|LINK
Try telling the Update panel to not do postbacks on it's children controls
ajitbhatti
Member
2 Points
6 Posts
Re: Jquery validate message disappearing in update panel
Oct 25, 2010 08:16 PM|LINK
That worked.. Thanks for the quick reply
Mr.Bill
Participant
1046 Points
375 Posts
Re: Jquery validate message disappearing in update panel
Apr 24, 2012 05:12 PM|LINK
The following consistantly fixes that issue for me: