0

Hello

In Form when I Select "Yes" in Radio button then Textbox Show with validation.(Submit button)
When Click on "No" then submit form without validation.

Here my code

    <form>
        <input type="radio" name="gender" value="yes" >yes
        <input type="radio" name="gender" value="no" checked="checked">No<br/><br/>
            <div id="disp_not">
                Company<input type="text" name="company" value="" id="company" /><br/><br/>
            </div>
        <input type="submit" value="Submit" id="submit"/>
    </form>

    *******************************************************************
    <script type="text/javascript">
    $(document).ready(function(){

        $("#disp_not").hide();
        $("input:radio").change(function(){
        var $value = $("form input[type='radio']:checked").val();

        if($value === 'no')
        {
            $(document).ready(function(){
            $("#disp_not").hide();
            });
        }
        else
        {
            $(document).ready(function(){
            $("#disp_not").show();
            });

            $("#submit").click(function(){
            var $company = $("#company").val();

                 if($company == '')
                {
                alert("Enter company name");
                }
            });

        }
    });
    });
    </script>

Suggest me for solution..

Thank You

2
Contributors
1
Reply
11
Views
3 Years
Discussion Span
Last Post by hericles
0

You're only creating the submit.click function if 'yes' is clicked. if $value == no then the function never exists.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.