Bugg error in validation
<p>Goal:<br>
To enable display a pop up if validation was correct or failure.</p>

<p>Problem:  </p>

<blockquote>
  <p>Somehow it doesn't want to make a
  validation of the password.</p>
</blockquote>

<p>I tried using Firebug but It can't make debugging for this code for some reason.</p>

<p>Before creating this validation I had this code before:</p>

<pre><code>    function validation() {
              if (mittXHRobjekt.readyState == 4)          
              alert("Okey");
     }
</code></pre>

<p>After doing more improvement by adding validation, The readyState don't work properly. All I did was to improve the function validation only.</p>

<hr>

<p>The current code with validation is:</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
&lt;head runat="server"&gt;
&lt;title&gt;Untitled 1&lt;/title&gt;
  &lt;script type="text/javascript"&gt;


      var mittXHRobjekt = null;

      function skapaXHRobjekt() {
          try {
              XHRobjekt = new XMLHttpRequest(); 
          } catch (err1) {
              try { 
                  XHRobjekt = new ActiveXObject("Microsoft.XMLHTTP");
              } catch (err2) {
                  try { 
                      XHRobjekt = new ActiveXObject("Msxml2.XMLHTTP");
                  } catch (err3) {
                      XHRobjekt = false;
                  }
              }
          }
          return XHRobjekt;
      }


      function validation() {
          if (mittXHRobjekt.readyState == 4) {

              if (window.document.frmPassword.txtPassword.value == mittXHRobjekt.responseText) {
                  alert("Correct password");
              }
              else {
                  alert("Wrong password");
              }

          }


          alert("no ready state 4");
      }




      function test(url) {
          mittXHRobjekt = skapaXHRobjekt();
          if (mittXHRobjekt) {
              mittXHRobjekt.onreadystatechange = validation;
              mittXHRobjekt.open("GET", url);
              mittXHRobjekt.send(null);
          }
      }




  &lt;/script&gt;



&lt;/head&gt;

&lt;body&gt;
    &lt;form id="frmPassword"&gt;
        &lt;input name="txtPassword" type="password" /&gt;
        &lt;input name="btnPassword" type="button" value="Evaluation" onclick="test('password.txt')" /&gt;
    &lt;/form&gt;
&lt;/body&gt;

&lt;/html&gt;
</code></pre>
