How to change lowercase chars to uppercase using the 'keyup' event?
Plain ol' javascript:
var input = document.getElementById('inputID');
input.onkeyup = function(){
this.value = this.value.toUpperCase();
}
Javascript with jQuery:
$('#inputID').keyup(function(){
this.value = this.value.toUpperCase();
});
The only issue with changing user input on the fly like this is how disconcerting it can look to the end user (they'll briefly see the lowercase chars jump to uppercase).
What you may want to consider instead is applying the following CSS style to the input field:
text-transform: uppercase;
That way, any text entered always appears in uppercase. The only drawback is that this is a purely visual change - the value of the input control (when viewed in the code behind) will retain the case as it was originally entered.
Simple to get around this though, force the input val() .toUpperCase(); then you've got the best of both worlds.
$(document).ready(function()
{
$('#yourtext').keyup(function()
{
$(this).val($(this).val().toUpperCase());
});
});
<textarea id="yourtext" rows="5" cols="20"></textarea>