Pages

Monday, 24 February 2014

JQuery radio button validation

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication4.WebForm1" %>

<!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></title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {

            $("#btn").hide();

            $("input[type=radio]").click(function () {

                check();
            });
        });
        var check = function () {

            if (($('input[name=color]').is(":checked")) && ($('input[name=size]').is(":checked"))) {

                $("#btn").show();

            }
            else {

                $("#btn").hide();

       
            }
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="radio" name="color" value="red" />red
        <br />
        <input type="radio" name="color" value="green" />green<br />
        <input type="radio" name="size" value="red" />36
        <br />
        <input type="radio" name="size" value="green" />38
    </div>
    <input type="button" id="btn" value="hi welcome" />
    </form>
</body>
</html>

No comments:

Post a Comment