Updating an input's value without losing cursor position
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/8219639/stop-cursor-from-jumping-to-end-of-input-field-in-javascript-replace">Stop cursor from jumping to end of input field in javascript replace</a>  </p>
</blockquote>



<p>I want to mandate that the value of a text box is lowercase, using JavaScript. I've tried the code below, but the cursor jumps to the end of the input every time you press a key. How can I avoid this?</p>

<pre><code>$("#beLowerCase").keyup(function(){
    $(this).val( $(this).val().toLowerCase() );
});
</code></pre>
