jQuery Validation at least one checkbox is selected

后端 未结 5 1747
鱼传尺愫
鱼传尺愫 2021-01-15 02:05

I have the following piece of html code for form checkboxes

5条回答
  •  时光取名叫无心
    2021-01-15 02:45

    This is very simple......

    function validate_form()
    {
    valid = true;
    
    if($('input[type=checkbox]:checked').length == 0)
    {
        alert ( "ERROR! Please select at least one checkbox" );
        valid = false;
    }
    
    return valid;
    }
    

    HTML

    Box1 Box2

提交回复
热议问题