Jquery problem with errorPlacement.
Posted
by Eyla
on Stack Overflow
See other posts from Stack Overflow
or by Eyla
Published on 2010-03-17T22:05:02Z
Indexed on
2010/03/17
22:11 UTC
Read the original article
Hit count: 260
Greetings,
I have problem with errorPlacement, I'm trying to place the error message next to the field but it appearing on the top of the page.
any advice how to fix this problem??
here is my code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="IMAM_APPLICATION.WebForm1" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script src="js/jquery-1.4.1.js" type="text/javascript"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#aspnetForm").validate({
groups: {
username: "fname lname",
address: "address1 phone"
},
errorPlacement: function(error, element) {
if (element.attr("name") == "fname"
|| element.attr("name") == "lname")
error.insertAfter("#lastname");
else
error.insertAfter(element);
},
debug: true
})
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<p style="height: 313px">
<label style="position:absolute; top: 227px; left: 22px;">Your Name</label>
<input name="fname" value="Pete"
style="position:absolute; top: 226px; left: 102px;"/>
<input name="lname" id="lastname"
style="position:absolute; top: 264px; left: 95px;"/>
<input name="address1" style="position:absolute; top: 347px; left: 102px;"/>
<input name="phone" id="lastname"
style="position:absolute; top: 315px; left: 102px;"/>
<br/>
<input type="submit" value="Submit Name" style="position:absolute; top: 407px; left: 73px;"/>
<input type="submit" value="Submit Address"
style="position:absolute; top: 370px; left: 437px;"/>
</p>
</asp:Content>
© Stack Overflow or respective owner