title: Check if two fields has the same value with javascript
body: <p><br>
  I want to make a form for registration and the form should have two fields for password, so there is no mix up.
  <br>
  So if the passwords are the same, there should be a green bock right to the field, and if not there should be a red cross..<br></p>
  
  <p>So here is my code for testing, but it doesn't work.</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
  function check()
  {
      var loc;
      if (test.name1.value == test.name2.value) {
          loc = "/img/greenbock.jpg";
      }
      if (test.name1.value != test.name2.value) {
          loc = "/img/redcross.jpg";
      }
      return loc;
  }
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form name="test" method="post" action=""&gt;
  Name&lt;br /&gt;
  &lt;input name="name1" type="text" /&gt;&lt;br /&gt;
  Name agian&lt;br /&gt;
  &lt;input name="name2" type="text" onblur="check()" /&gt;
  &lt;script language="javascript" type="text/javascript"&gt;
  if(loc != "")
  {
  document.write("&lt;div style=\"height:19px; width:20px; background-image:url("+ loc + ")\"&gt;&lt;/div&gt;");
  }
  &lt;/script&gt;
  &lt;br /&gt;
  Username&lt;br /&gt;
  &lt;input name="username" type="text" /&gt;&lt;br /&gt;
  </code></pre>
  
  <p>So where am I wrong? A little fault or, should i thruw everything away?</p>
  
  <p>[edit]
  <br> 
  Now I have set the check-function to run the script after input. So now its doing samething, because everything disapears.. Solutions?</p>