Javascript - use of indexOf to search for strings
<p>In the first block, I make sure the password does not contain 'password'.  It works perfectly.</p>

<pre><code>  var element=document.getElementById('password');
  if (element.value.toLowerCase().indexOf('password') &gt; -1){ //returns 0 or more if present
    alert('Password may not contain the word `password`.');
    element.focus();
    return false;
  }
</code></pre>

<p>In the second block I check that the password does not containthe firstname, it does not work, what have I done wrong?</p>

<pre><code>  //stop password of firstname
  var element=document.getElementById('password');
  var firstname=document.getElementById('firstname');
  if (element.value.toLowerCase().indexOf(firstname.value) &gt; -1){ //returns 0 or more if present
    alert('Password may not contain the firstname.');
    element.focus();
    return false;
  }
</code></pre>
