title: jQuery client side password verification
body: <p>first of all I'd like to say <strong>I realise</strong> it's not a secure method.
  This is only for training purpose.</p>
  
  <p>The algorhitm should be:</p>
  
  <ol>
  <li>click on a div with id="login-bg"</li>
  <li>app displays the banner</li>
  <li>provide the code</li>
  <li>if the code's ok set cookie and fade out the banner</li>
  <li>if the code's not ok the div shakes (still remaining on the screen)</li>
  <li>if you don't want to provide the code press 'cancel' and fade out the banner</li>
  </ol>
  
  <p>Set cookie function (it works fine):</p>
  
  <pre><code>&lt;?php
      if(!isset($_COOKIE['is_logged']))
          { ?&gt;
          &lt;script type="text/javascript"&gt;
          function SetPwd(c_name,value,expiredays){
              var exdate=new Date()
              exdate.setDate(exdate.getDate()+expiredays)
              document.cookie=c_name+ "=" +escape(value)+";path=/"+             ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
              }
          &lt;/script&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p><strong>And here must be the problem with jQuery:</strong></p>
  
  <pre><code>&lt;?php
          if(!isset($_COOKIE['is_logged']))
          { ?&gt;
          &lt;div id="login-bg"&gt;
              &lt;div class="content"&gt;
                  &lt;h2&gt;Provide the code!&lt;/h2&gt;
                  &lt;form id="check-form" method="post" action=""&gt;
                      &lt;input type="password" name="code" placeholder="code" id="code" /&gt;
                      &lt;input type="submit" value="Submit" id="enjoy"/&gt; 
                  &lt;/form&gt;
                  &lt;h3&gt;And enjoy free access!&lt;/h3&gt;
                  &lt;a id="cancel"&gt;Cancel&lt;/a&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;script type="text/javascript"&gt;
          $(document).ready(function() {
              if( document.cookie.indexOf("is_logged") ===-1 ){
                  $('#video').click(function(){
                      $("#login-bg").fadeIn('slow');
                  });
                  $('#cancel').click(function(){
                      $('#login-bg').fadeOut('slow');
                      //window.location = "&lt;?php echo $this-&gt;baseUrl; ?&gt;/index";
                  });
              }
              $("#submit").click(function (){
                  var value = $('#code').val();
                  var pass = 'test';
                  if( value == test ){
                      SetCookie('is_logged','is_logged',365*10)
                      $("#login-bg").remove();
                  }
                  else { 
                      $('#login-bg').effect( "shake" );
                  }
              });
          });
          &lt;/script&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>In my opinion the value '#code' id not passed to jQuery from the form.<br>
  But I may be wrong.</p>
  
  <p>Do you have any ideas. Could you make it work?<br>
  Thanks for your help.</p>