I tried "is" function but it is not work in asp.net. I just want to check if the box is select, if not keep in this page and show notice message.
Code:
 @foreach (var f in gs.Set.Facets)
         {
            <li>
               <label>
                  <input type="@(gs.Set.AllowMultipleSelection ? "checkbox" : "radio")" 
                     name="FacetResults" 
                     value="@f.FacetID"@(ViewData.Model.FacetStates[f.FacetID] ? " checked=\"checked\"" : "")  class="sel"/>
                     @f.LabelText
               </label>
            </li>
         }
   <inpu开发者_开发知识库t type="submit" value="Complete" id = "Complete" />
Try this
$("#Complete").click(function(){
  if(!$("input:checkbox[name='FacetResults']").is(":checked")){
      return false;
  }
});
It depends on where you want that logic. Shankar's answer is great if you want the validation explicitly in the javascript, however I tend to prefer a ViewModel with Data Annotations approach.
Use jQuery's .each() function to check each checkbox's state:
$('#Complete').click(function () {
    var isSelected = false;
    $('input:checkbox[name="FacetResults"]').each(function (index) {
        if ($(this).attr('checked')) {
            isSelected = true;
        }
    });
    alert(isSelected);
    return isSelected;
});
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论