0

i have a grid with data colection and every row have a checkbox, i need ask: if any checkbox is not checked, show an alert message.

my code is:

  var count = 0;
        $('#checkableGrid').find("input:checkbox:is(:checked)").each(function () {
            count++;
        });     
        if (count == 0) {
            alert("must check any item");
            return false;
        };
s_sanchez
  • 25
  • 4
  • possible duplicate of [jQuery see if any or no checkboxes are selected](http://stackoverflow.com/questions/4086957/jquery-see-if-any-or-no-checkboxes-are-selected) – isherwood Dec 11 '14 at 13:47

1 Answers1

2

you have incorrect selector to target all input checkbox:

 if(!$('#checkableGrid').find("input:checkbox:checked").length){
        alert("must check any item");
        return false;
 };
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125