Struggling with some javascript, password / username error display
<p>Note, I will validate everything with PHP on form submission, but I'd like to display it instantly to the user if possible.</p>

<p>For the username I am trying to detect if it only contains whitespace, if it's less than 8 chars/numbers and if it only contains normal valid letters and no symbols.</p>

<p>This does not seem to work:</p>

<pre><code>$("#username").change(function() {
  $("#username").removeClass("error");
  var letterNumber = /^[0-9a-zA-Z]+$/;
  var username = $("#username").val(); // get value of password
  if (!(username.value.match(letterNumber)) {
    // return error
  }
  if (username.length &lt; 8) {
    // return error
  }
  if (username.trim().length() &gt; 0) {
    // return error
  }
});
</code></pre>

<p>And for the password, I want to allow all symbols, all numbers, all letters, minimum 8, and trim for whitespace. It does not seem to work though.</p>
