title: Javascript - stop proceeding after alert message
body: <p>In my web application, in the login page, I have a checkbox. After entering the username/password, if the user doesn't tick the checkbox (T&amp;C), he should not be taken to the home page, and an alert error message will be shown.</p>
  
  <p>I have tried the following code. But it is not working. That is, an alert message is shown. But the user is taken to the next page(home page). I tried returning false, but no luck.</p>
  
  <p>Can anyone tell how to fix this?</p>
  
  <pre><code>function doSubmit() {
      var checkbox = document.getElementById("terms");
      if (!checkbox.checked) {
          alert("error message here!");
          return;
      }
      document.getElementById("f").submit();
  }​  
  </code></pre>
  
  <p>I am calling doSubmit from  </p>
  
  <pre><code>&lt;input id="proceed" onclick="doSubmit()" type="submit" value="${fn:escapeXml(submit_label)}" /&gt;
  </code></pre>