validate plugin not working with master page in asp.net
I am using jquery validate plugin with my asp project. I am using Master Page and Content Page.
But there is no validation showing on my pages. I checked my project pages with chrome and firefox but there were no errors showing in console too. Please can anyone help me with this problem.
code of Master Page
- // master page
- <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Global.master.cs" Inherits="MIS.content.Global" %>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <script type="text/javascript" src="../Scripts/jquery-3.1.1.min.js"></script>
- <script type="text/javascript" src="../Scripts/jquery.validate.min.js"></script>
- <script type="text/javascript" src="../Scripts/jquery.validation.net.webforms.min.js"></script>
- <asp:ContentPlaceHolder ID="head" runat="server">
- </asp:ContentPlaceHolder>
- </head>
- <body>
- <form id="form1" runat="server">
- <div id="container">
- <div id="tray">
- testing
- </div>
- <div id="cols">
- <div id="aside">
- </div>
- <div id="content">
- <div id="main_content">
- <div>
- <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
- </asp:ContentPlaceHolder>
- </div>
- </div>
- </div>
- </div>
- </div>
- </form>
- </body>
- </html>
code of my content page (aspx page)
- // aspx page
- <%@ Page Language="C#" MasterPageFile="Global.master" AutoEventWireup="true" CodeBehind="CustomerRegistration.aspx.cs" Inherits="MIS.content.CustomerRegistration" %>
- <asp:Content ID="UserContent" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
- <script type="text/javascript">
- $(document).ready(function() {
- $("#aspnetForm").validate({
- rules: {
- <%=txt_name.UniqueID %>: {
- minlength: 2,
- required: true
- },
- <%=txt_gender.UniqueID %>: {
- required: true,
- email:true
- }
- }, messages: {}
- });
- });
- </script>
- <div style="width: 100%; font-family: Arial,Helvetica, sans-serif;">
- <div style="text-align: left; width: 100%; font-size: 13px; margin-bottom: 5px;">
- <b>Name :</b>
- <asp:textbox id="txt_name" runat="server" />
- </div>
- <div style="text-align: left; width: 100%; font-size: 13px; margin-bottom: 5px;">
- <b>Gender :</b>
- <asp:textbox id="txt_gender" runat="server" />
- </div>
- <div style="text-align: left; width: 100%; font-size: 13px; margin-bottom: 5px;">
- <asp:button id="btnSubmit" runat="server" text="Submit" />
- </div>
- </div>
- </asp:Content>