Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text-transform:uppercase bug in Google Chrome v.22 [closed]

I've come across a bug (since last week) in Chrome (Version 22.0.1229.79) with some javascript that is attempting to convert a field value to uppercase. It seems to be conflicting with CSS (text-transform:uppercase) that is making the field value look uppercase at the same time.
When tabbing out of the field, the onChange event handler will attempt to change the field value into uppercase, but the result is that the field becomes empty. But if you try typing into the field again, your previous text reappears.

Has anyone else seen the same thing? I think it needs reporting to Google.

Here is a test case for it... http://jsfiddle.net/fhBx2/2/

<script>
function upperKey(obj) 
{
    var val = obj.value;
    if(val != null)
    {
        obj.value = val.toUpperCase();
    }    
}
</script>

<input type="text" style="text-transform:uppercase;" 
onchange="upperKey(this);"/>
like image 844
bishbashbosh Avatar asked Oct 01 '12 09:10

bishbashbosh


1 Answers

For anyone who actually has an issue with this, I've found that you can do a workaround by resetting the value to blank and then back to the original value, but uppercased.

$(function() {
    $('input').change(function(e) {
        var val = $(this).val().toUpperCase();
        $(this).val('').val(val);
    });
});​

See the updated fiddle: http://jsfiddle.net/JXA8K/2/

like image 118
Kyle Avatar answered Oct 20 '22 00:10

Kyle