title: Javascript onsubmit="" not working
body: <p>I'm not sure if my error comes from submitting the form to itself via PHP but it is just not hitting my function and submits anyway no matter what is returned. I'm not sure what I'm missing here. This is my form</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Login Page&lt;/title&gt;
      &lt;script type="text/javascript" src="js/functions.js"&gt;&lt;/script&gt;
      &lt;!--Internal for simplicity or until bigger page --&gt;
      &lt;style type="text/css"&gt; 
          #login div{display:inline;color:red;}
          input{margin-right:20px;}
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form name="login" id="login" action="&lt;?php $_SERVER['PHP_SELF'] ?&gt;" method="POST" onsubmit="return CheckLogin()"&gt;
      &lt;?php if($_POST &amp;&amp; $win == false): ?&gt;
          &lt;div&gt;Login Unsuccessful. Please Try Again&lt;/div&gt;&lt;br /&gt;
      &lt;?php endif ?&gt;
          &lt;input type="text" size="10" name="username" /&gt;&lt;div&gt;&lt;/div&gt;
              &lt;br /&gt;
          &lt;input type="password" size="10" name="password" /&gt;&lt;div&gt;&lt;/div&gt;
              &lt;br /&gt;
      &lt;input type="submit" text="Submit" /&gt;
  &lt;/form&gt;
  &lt;a href="register.php"&gt;Registration Page&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Really I'm just checking if username/password are empty but it just submits anyway going right through this function:</p>
  
  <pre><code>function CheckLogin()
  {
      window.alert("made it here");
      var login = document.forms["login"];
      var user = login["username"].value;
      var pass = login["password"].value;
  
      if(user == null || user == "")
      {
          window.alert("user");
          return false;
      }  
  
      return false;
  }
  </code></pre>
  
  <p>I'm sure it's something stupid that I'm missing so before I submitted this I double checked the function names and to see if I was getting any javascript errors but neither turned out to be the problem. Does anybody see my error?</p>
  
  <p>The point being I do not want the PHP to run or the form to be submitted to itself if username or password is empty or null.</p>
  
  <p><strong>EDIT</strong> Added full html page minus the PHP functionality. Also noted that for some reason my javascript link does not 'link' instead I can view the contents of it directly in the header like it is embedded via inspect element or firebug. This might be the root of the problem but not sure why.</p>
  
  <p><strong>EDIT</strong> Added doctype just incase, but still no help. It is automatically embedding my javascript into my page and putting it into CDATA like you would normally instead of actually linking it. It does this in IE, Firefox &amp; Chrome...</p>
  
  <p>if anyone thinks my PHP might have something to do with it I could post it, but I don't see how server side code could interact with client side code without being posted.</p>