Question: I have looked for hours on the web with no luck!

I have 40 Check boxes, one check box must be checked at all times. Here's the twist, that one check box must be any one of the 40.

I know how to target just one single button...this is not the goal. The user must be able to choose which one is to remain active.

```
      $(document).ready(function() {
      $('#W_E-helpPage01').click(function() {
         return false;

```

As for form validation that's not the ticket either. As this needs to be dynamic, it must prevent the user from deselecting all but one check box.

Example:
If 30 where to be check, and the user decided to uncheck all 30 he can not do this. As the rule is there must always be at-less one check, it doesn't matter which one but it must be random.

Any help would be greatly appreciated.

Thanks,
Ricky

Answer: 
This code will stop the user from unchecking the last checked checkbox:

```
$('input:checkbox').on('click', function() {    
    if ($('input:checkbox:checked').length == 0) {
        return false;
    }
});​

```

It checks to see if this click results in there being no checked check boxes and cancels the click if that is true.

<http://jsfiddle.net/BQCK3/>
```
Please use the following example

 <input  class="Active test" type="checkbox" checked /><span>1</span><br />
 <input  class="InActive test" test" type="checkbox" /><span>2</span><br />
 <input  class="InActive test" test" type="checkbox" /><span>3</span><br />
 <input  class="InActive test" test" type="checkbox" /><span>4</span><br />
 <input  class="InActive test" test" type="checkbox" /><span>5</span><br />
 <input class="InActive test" type="checkbox" /><span>6</span><br />

 $('.test').live('click', function () {
    if ($(this).hasClass("Active")) {
        $(this).removeClass("Active");
        $(this).addClass("InActive");
    }
    else
        if ($(this).hasClass("InActive")) {
            $(this).removeClass("InActive");
            $(this).addClass("Active");
        }
    // alert($('.Active').length);
    if ($('.Active').length == 0) {
        alert("Atleast one checkbox is required")
        $(this).addClass("Active");
        return false;
    }
});

```