title: Check for Space character in input with Jquery
body: <p>I have a form where a user will set up a new Username. The issue is user's have been creating username's with a space and I want to avoid that. </p>
  
  <p>I have been able to detect when there is a space using the following:</p>
  
  <pre><code>var hasSpace = $('#usernameValue').val().indexOf(' ')&gt;=0;
  </code></pre>
  
  <p>However I cannot figure out to have the form check for that space when the user is typing in that input section.</p>
  
  <p>How would I change my code to do this?</p>
  
  <p>Thank you!</p>