This can be a fragile approach. If for whatever reason the count gets confused, you might end up with a state, where the button can't be pressed, even if it should be possible. A safer way to check the state would be to always count the actual checkboxes.