开发者

how to make condition on selection of checkbox in user controler

I have a user control:

<input id="check" type="checkbox" />  
 <label>&nbsp;</开发者_如何学Clabel>  
<fieldset class="clearfix" id="fieldset-exception">
    <legend>Student Information</legend>
    <div class="fiveper">
        <label for="StudentID">
            Exception ID:
            <span><%=Html.EditorFor(x => x.studentid)%></span>
        </label>
        <label for="Classroom">
            Origination:
            <span><%=Html.EditorFor(model => model.Classroom)%></span>
        </label>
        <label for="Subject">
            Age:
            <span><%=Html.EditorFor(model => model.subject)%></span>
        </label>
</div>
 $('#btnAll').click(function() {
           $('#Details input[type=checkbox]').attr('checked', 'checked');
        });

I am checking all checkboxes using above code but I need to make condition here that user need to select at least one checkbox to do something?

I have other button to go other page based on this checkbox checked?

can anybody tell me how to check that and how to make that condition here?


try the following:

if ($("#Details input[@type=checkbox][@checked]").length < 1){
     return false;
}

have your button's onclick call this method, and only submit if it doesn't return false.


try something like this

if ( $('#Details input[@type=checkbox][@checked]').length < 1 ) {
    //error
}

youll also want to implement this server-side as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜