locked
validation using jquery RRS feed

  • Question

  • User582566331 posted

    Valiadtion using jquery is not working in content pages.Please help me..

    My code is as follows

    Master Page

    <%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site1.master.vb" Inherits="validation.Site1" %>

    <!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 runat="server">
    <title>Untitled Page</title>


    <link href="css/template.css" rel="stylesheet" type="text/css" />
    <link href="css/validationEngine.jquery.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="js/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>


    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
    </head>
    <body>
    <form id="form1" runat="server">

    <div>
    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

    </asp:ContentPlaceHolder>
    </div>
    </form>
    </body>
    </html>

    Content Page

    <%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="WebForm2.aspx.vb" Inherits="validation.WebForm2"
    title="Untitled Page" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    </asp:Content>

    <asp:Content ID="form1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript">
    function pageLoad()
    {
    jQuery("#aspnetForm").validationEngine();
    }
    </script>

    <table align="center">
    <tr>
    <td colspan="2">
    <div style="border: 1px solid #CCCCCC; padding: 10px;">
    <table cellpadding="0" cellspacing="30" style=" background-color:White">
    <tr>
    <td>First Name:</td>
    <%--<td><asp:TextBox ID="txtfname" runat="server" CssClass="validate[required],equals[<%= txtfname.ClientID %>]" name="ctl00$MainContent$txtfname"/></td>--%>

    <td><asp:TextBox ID="txtfname" runat="server" CssClass="validate[required],equals[<%= txtfname.ClientID %>]" /></td>
    <asp:Label ID = "alertFname" runat="server" />
    </tr>
    </tr>

    <tr>
    <td><asp:Label ID = "alert" runat="server" /></td>
    </tr>

    <tr>
    <td>Last Name:</td>
    <td><asp:TextBox ID="txtlname" runat="server" CssClass="validate[required]"/></td>
    </tr>
    <tr >
    <td>Email:</td>
    <td><asp:TextBox ID="txtemail" runat="server" CssClass="validate[required,custom[email]" />
    </td>
    </tr>
    <tr >
    <td>Url:</td>
    <td><asp:TextBox ID="txtUrl" runat="server" CssClass="validate[required,custom[url]] text-input" />
    </td>
    </tr>
    <tr>
    <td valign="top">Address:</td>
    <td>
    <asp:TextBox ID="txtaddress" runat="server" TextMode="MultiLine" Rows="8" Columns="26"/></td>
    </tr>
    <tr>
    <td>State:</td>
    <td>
    <asp:DropDownList ID="ddlState" runat="server" CssClass="validate[required] radio">
    <asp:ListItem value="">Choose State</asp:ListItem>
    <asp:ListItem Value="AL">Alabama</asp:ListItem>
    <asp:ListItem value="AK">Alaska</asp:ListItem>
    <asp:ListItem value="AL">Alabama </asp:ListItem>
    <asp:ListItem value="AK">Alaska</asp:ListItem>
    <asp:ListItem value="AZ">Arizona</asp:ListItem>
    <asp:ListItem value="AR">Arkansas</asp:ListItem>
    <asp:ListItem value="CA">California</asp:ListItem>
    <asp:ListItem value="CO">Colorado</asp:ListItem>
    <asp:ListItem value="CT">Connecticut</asp:ListItem>
    <asp:ListItem value="DE">Delaware</asp:ListItem>
    <asp:ListItem value="FL">Florida</asp:ListItem>
    <asp:ListItem value="GA">Georgia</asp:ListItem>
    <asp:ListItem value="HI">Hawaii</asp:ListItem>
    <asp:ListItem value="ID">Idaho</asp:ListItem>
    </asp:DropDownList>
    </td>
    </tr>
    <tr>
    <td>Zip:</td>
    <td>
    <asp:TextBox ID="txtZip" runat="server" CssClass="validate[required,custom[integer]] text-input"/>
    </td>
    </tr>
    <tr>
    <td> I Agree Conditions</td>
    <td>
    <input class="validate[required] checkbox" type="checkbox" id="agree" name="agree"/>
    </td>
    </tr>
    <tr>
    <td></td>
    <td>
    <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick ="showLbl();" />
    <asp:Button ID="ZZZZZ" runat="server" Text="Test" UseSubmitBehavior="false"/>
    </td>
    </tr>
    <tr>
    <td colspan="2">
    <asp:Label ID="lblResult" runat="server" Font-Bold="true"/>
    </td>
    </tr>
    </table>


    </asp:Content>

    Wednesday, November 25, 2015 5:51 AM

Answers

  • User61956409 posted

    Hi sweetyPaul,

    It seems that you’d like to use jQuery validationEngine plugin to validate the form fields. According to your code, we could find that you attach jQuery validationEngine plugin to <form> element in pageLoad() function, but you don’t call this function. Besides, please make sure if your <form> element with a ID named “aspnetForm”. And you could initiate jQuery validationEngine plugin when document is ready, like this.

    <script>
        $(document).ready(function () {
            $("#formID").validationEngine();
        });
    </script>
    

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 26, 2015 2:34 AM