Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>

    <script type="text/javascript" language="javascript">
        $(document).ready(function ()
        {
            $("#form1").validate({

                rules: {
                    "<%=txtName.ClientID %>": {
                        required: true
                    },
                },
                messages: {
                    "<%=txtName.ClientID %>": {
                        required: "Name should not be empty"
                    },
                }

            });
        });
    </script>

    <style type="text/css">
        label.error {
            color: red;
            display: inline;
        }

        .error {
            height: 26px;
        }
    </style>

</head>
<body>
    <form id="form1" runat="server">
        Name <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="error" onclick="btnSubmit_Click" />
    </form>
</body>
</html>

for the above i download the jquery 1.4.1 js and min.js and put into the script folder inside the project

when i run the screen and click the submit button the message
C#
Name should not be empty is not displaying.

please help me what is the mistake in my above code.

What I have tried:

Tried the below code but it is not working
Posted
Updated 19-Jun-16 4:50am
v2

1 solution

jQuery Validation Plugin | Form validation with jQuery[^]
As in its name: it is a plugin and not integral part of jQuery...
You have to include jQuery Validator JavaScriot file too...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900