Determine if every radio group has had an option selected

后端 未结 6 1901
南旧
南旧 2020-12-21 02:18

I need to make sure that all the radio groups have been answered before I enable the submit button. If I have:

var radioBtns = $(\'input\').filter(\':radio\         


        
6条回答
  •  情歌与酒
    2020-12-21 02:42

    not very neat way but still you can use it

    $("input:button").click(function(){
        var v =$('input[name="a"]').filter(':checked');
        var vr =$('input[name="b"]').filter(':checked');
        if(v.length==0)
        {
        alert("select a group");
    
        }else alert("very good");
    
    
        if(vr.length==0)
        {
        alert(" o come on ");
    
        }else alert("guud");
    
        });
    

    FIDDLE

提交回复
热议问题