JQuery Require Checkbox and Radio Button before submit

后端 未结 3 1098
小鲜肉
小鲜肉 2021-01-31 22:29

I am having one heck of a hard time trying to figure this out. Been looking at examples and tools for JQuery validation for over 3 hours now.

All I want to do is require

3条回答
  •  鱼传尺愫
    2021-01-31 23:24

    $('#form1').submit(function(){
        if ($(':checkbox:checked', this)[0] && $(':radio:checked', this)[0]) {
            // everything's fine...
        } else {
            alert('Please select something!');
            return false;
        }
    });
    

提交回复
热议问题