title: Grab text input as the user types
body: <p>I'm trying to update a span tag on the fly with data from an input text field. Basically I have a text field and I'd like to be able to grab the user's input as they type it and show it to them in a span tag below the field.</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;input id="profileurl" type="text"&gt;
  &lt;p class="url"&gt;http://www.randomsite.com/&lt;span id="url-displayname"&gt;username&lt;/span&gt;&lt;/p&gt;
  </code></pre>
  
  <p>JQuery:</p>
  
  <pre><code>var username;
  
  $('#profileurl').keyup(function(username);
  $("#url-displayname").html(username);
  </code></pre>
  
  <p>See it in JS Fiddle: <a href="http://jsfiddle.net/pQ3j9/" rel="nofollow">http://jsfiddle.net/pQ3j9/</a></p>
  
  <p>I'm guessing the keyup function is not the best way to do this. Since checking the key wouldn't be able to grab prefilled or pasted form input.</p>
  
  <p>Ideally there is some magical jQuery function that can just output whatever info is in the box whenever it detects a key up but if that method exists I haven't found it yet.</p>
  
  <p><strong>EDIT:</strong> You guys are fricken amazing. It looks like .val() is that magic method.</p>
  
  <p><strong>Second question:</strong> How would you restrict input? Looking at the modified jsfiddle's, when a user inputs an html tag like &lt; hr > the browser interprets it and breaks the form. Do you specify an array and then check against that? Does jquery have anything like PHP's strip_tags function?</p>