need to select atleast one checkbox using javascript
<p>I am using this javascript code. and on button click I want that atleast one checkbox selection is required. do anyone have idea what I am doing wrong. I don't want to use jquery. 
    </p>

<pre><code>function check()
{
var flag = false;
for(var i=1;i&lt;=4;i++)
{
  var checkb = document.getElementById("check"+i);

  if(checkb.checked)
  {
    flag = true;
    break;
  }
}
if(!flag)
alert("What is your interest \n(select at least one option)");
return flag;
}
&lt;/script&gt;
</code></pre>

<p>Button Click Code is </p>

<pre><code>&lt;input type="submit" name="submit" value="Submit" onclick="return check();"&gt;
</code></pre>
