jQuery errorContainer practice

Posted by Eyla on Stack Overflow See other posts from Stack Overflow or by Eyla
Published on 2010-03-18T17:35:08Z Indexed on 2010/03/18 17:41 UTC
Read the original article Hit count: 150

Filed under:
|

I'm trying to be able to place the error message when using jQuery validation to a asp.net label if the text message is empty.

please advice how to modify my code to get that!!

here is my code:

<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({
            errorContainer: "#<%=TextBox1 %>",
            errorLabelContainer: "#<%=TextBox1 %> #<%=Label1 %>",
                wrapper: "li", debug: true,
                submitHandler: function() { alert("Submitted!") }
            })
        });


    </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">

        <asp:TextBox ID="TextBox1" runat="server" class="required"></asp:TextBox>
        <asp:Label ID="Label1" runat="server" Text="Label"  ></asp:Label>  

    </p>




    </asp:Content>

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about jQuery