vendredi 31 juillet 2015

How to display an error if the check box is not checked? [duplicate]

This question already has an answer here:

I am a newbie in jquery

3 hours how to solve this problem, but does not work

How to display an error if the checkbox is not checked?

I would be glad of any help

My code

Fiddle

$("#test_inner .test-item").each(function (e) {
        if (e != 0) $(this).hide();
    });

    var i = 0;
    $(".next-btn").click(function () {
        i++;
        if (i == 3) {
            $(this).hide();
        }
        if ($("#test_inner .test-item:visible").next().length != 0) $("#test_inner .test-item:visible").next().show().prev().hide();
        else {
            $("#test_inner .test-item:visible").hide();
            $("#test_inner .test-item:first").show();
        }
        return false;
    });
<script src="http://ift.tt/VorFZx"></script>
<div id="test_inner">
    <div class="test-item">DIV1
        <br/>
        <label><input type="radio" name="r1" value="1" />1</label><label>
            <input type="radio" name="r1" value="2" />2</label><label>
            <input type="radio" name="r1" value="3" />3</label>
        </div>
    <div class="test-item">DIV2
        <br/>
        <label><input type="radio" name="r2" value="1" />1</label>
        <label><input type="radio" name="r2" value="2" />2</label>
        <label><input type="radio" name="r2" value="3" />3</label>
    </div>
    <div class="test-item">DIV3
        <br/>
        <label><input type="radio" name="r3" value="1" />1</label>
        <label><input type="radio" name="r3" value="2" />2</label>
        <label><input type="radio" name="r3" value="3" />3</label>
    </div>
    <div class="test-item">DIV4
        <br/>
        <label><input type="radio" name="r4" value="1" />1</label>
        <label><input type="radio" name="r4" value="2" />2</label>
        <label><input type="radio" name="r4" value="3" />3</label>
    </div>    
    
    <a href="#" class="next-btn">send</a>

</div>

Thank you in advance

Aucun commentaire:

Enregistrer un commentaire