title: How can I check if a checkbox is checked?
body: <p>I am building a mobile web app with jQuery Mobile and I want to check if a checkbox is checked. Here is my code.</p>
  
  <pre><code>&lt;script type=text/javascript&gt;
    function validate(){
      if (remember.checked == 1){
        alert("checked") ;
      } else {
        alert("You didn't check it! Let me check it for you.")
      }
    }
  &lt;/script&gt;
  
  &lt;input id="remember" name="remember" type="checkbox" onclick="validate()" /&gt;
  </code></pre>
  
  <p>But for some reason or another it doesn't execute it.</p>
  
  <p>Please help !</p>
  
  <p>----EDIT-----
  This is what I have for the moment.</p>
  
  <pre><code>&lt;DIV data-role="content" data-theme="g"&gt;
      &lt;DIV class=ui-grid-g-login&gt;
          &lt;FORM method=post action=[$=PROBE(266)/] data-theme="C"&gt;
              &lt;P&gt;~DATA_ERROR~&lt;/P&gt;
              &lt;div id="mail" data-role="fieldcontain"&gt;
                  &lt;label for="mail"&gt;Email:*&lt;/label&gt;       
                  &lt;input id="mail" name="mail" type="email" /&gt;
              &lt;/div&gt;
              &lt;div id="pass" data-role="fieldcontain"&gt;
                  &lt;label for="pass"&gt;Paswoord:*&lt;/label&gt;        
                  &lt;input id="pass" name="pass" type="password" /&gt;
              &lt;/div&gt;
              &lt;div id="remember" data-role="fieldcontain"&gt;
                  &lt;label for="remember"&gt;Onthoud mij&lt;/label&gt;       
                  &lt;input id="remember" name="remember" type="checkbox" onclick="validate()" /&gt;
              &lt;/div&gt;
              &lt;P&gt;&lt;INPUT class=btn name=submit value=Login type=submit  onclick="validate()"&gt;&lt;/P&gt;  
          &lt;/FORM&gt;
      &lt;/DIV&gt;
  &lt;/DIV&gt;&lt;!-- /content --&gt;
  
  &lt;script type=text/javascript&gt;
  function validate(){
      var remember = document.getElementById('remember');
      if (remember.checked){
          alert("checked") ;
      }else{
          alert("You didn't check it! Let me check it for you.")
      }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>----EDIT--</p>
  
  <p>Solved it, the problem was that the fieldcontain was also named 'remember'</p>