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);"/>
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With