Check Terms and Conditions Checkbox Checked or Not Using jQuery Validation

Check Terms & Condition


 JQuery Validation for terms and conditions checkbox checked or not  check Terms and Conditions checkbox selected or not using jQuery or restrict user to accept terms and conditions using jQuery.

If  Checked Checkbox  After  Control  to Agreed  Terms and Conditions.

if  Not Checked  checkbox Control  to Not Agreed  Terms and Conditions.



DEMO




  JQuery Coding


 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
    <title></title>

     <%--  Terms Condition  JQuery Coding Start--%>

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#btnSave').click(function () {
                if ($('#ChkTermsCondition').is(':checked')) {
                    alert('Your Agreed Terms & Conditions')
                }
                else {
                    alert('please check terms & conditions')
                }
            })
        })
    </script>

        <%--  Terms Condition  JQuery Coding End--%>

      </head>
   <body>
    <form id="form1" runat="server">
    <div>              
          <table>

            <tr><td>
                <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
                </td><td>
                    <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                </td></tr>
               <tr><td>
                <asp:Label ID="Label2" runat="server" Text="Mobile"></asp:Label>
                </td><td>
                    <asp:TextBox ID="txtMobile" runat="server"></asp:TextBox>
                </td></tr>
            <tr><td> Check Status:</td><td>
                <asp:CheckBox ID="ChkTermsCondition" runat="server" />
          Agree Terms & Conditions</td></tr>
            <tr><td></td><td><asp:Button ID="btnSave" runat="server" Text="Check"  />
                </td></tr>
                           
        </table>
    </div>
    </form>
</body>

</html>


First - Add Web Form - Select  Labels & Textboxes & Chexkbox & Button


Name - Textbox Id change (required).







Next  -  CheckBox Id  Name Change (Required)









Next - Change Button Id(Required)









Next  - JQuery   Coding for  Check Terms & Conditions 










Next - Coding for  Labels & Textboxes & CheckBoxes







                 


Next - F5 Run the WebForm -  Click the Check Button & UnSelect CheckBox








PopUp Show  - Check the Terms & Conditions










Next - Click the Check Button & Select  CheckBox









PopUp Show Agreed  Terms & Condition







                

0 comments:

Post a Comment