title: How to check values from a form before submitting it?
body: <p><strong>What I want to do:</strong></p>
  
  <p>When I click on a submit button (which goes to for example Google) my script should...</p>
  
  <ol>
  <li>append a "loading.gif" to a DIV with the ID = #loading to simulate that the page is loading and after that</li>
  <li>check if the user filled out a form correctly. If not, a popup should appear.</li>
  <li>After that it should go to GOOGLE</li>
  </ol>
  
  <p>I know it is quite easy but I can't find the mistake in my code so far. My JSFiddle: <a href="http://jsfiddle.net/cZshY/" rel="nofollow">http://jsfiddle.net/cZshY/</a></p>
  
  <p><strong>Example</strong>
  If someone puts the wrong university (Berlin instead of Hamburg) into the "university" field this should happen:</p>
  
  <ul>
  <li>A loading.gif should appear.</li>
  <li>After that a message should pop-up ("wrong university")</li>
  </ul>
  
  <p><strong>My HTML:</strong></p>
  
  <pre><code>&lt;div&gt;
      &lt;form&gt;
          &lt;p&gt;Nickname: &lt;input name="name" type="text" id="nickname"&gt;&lt;/p&gt;
          &lt;p&gt;University: &lt;input name="university" type="text" id="univer" value="University of Berlin"&gt;
          &lt;p&gt;Login: &lt;input name="login" type="text" id="loginData" value="LE_StuRa"&gt;&lt;/p&gt;
          &lt;p&gt;Password:&lt;input name="passwordfield" type="password" id="passw" value="34kle1"&gt;&lt;/p&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;div id="loading"&gt;&lt;/div&gt;
  
  &lt;form action="http://google.com"&gt;
      &lt;input type="submit" value="Continue" id="googleButton"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>My Javascript/jquery:</strong></p>
  
  <pre><code>$(document).ready(function(){
      $("#googleButton").click(function(){                
          var load = $("&lt;img src='http://www.tj-auctions.com/images/loading.gif'/&gt;"); 
          $(load).prependTo("#loading").fadeOut(3000, function(){
  
              if ( $("#loginData").val() != "LE_StuRa" || $("#univer").val() != "University of Hamburg" ) {
                  alert ("Wrong login data");
                  return false;
              }; 
  
              if ( $("#passw").val() != "34kle1" ) {
                  alert ("Wrong password");
                  return false;
              };
  
              if ( !$("#nickname").val() ) {
                  alert ("Please enter a nickname!");
                  return false;
              });
  
          }); 
      });
  });
  </code></pre>