I have a bit of code on my website to turn users text input into all uppercase letters. I thought it was working fine until someone pointed out that on their mobile phone a strange glitch occurs. As the user types into the textbox, it inserts extra letters as the user types, so for example, if they are trying to type 'BOB' it changes to 'BOBOB' or if they type 'DAD' it becomes 'DADAD'.
I've replicated this issue on two different Android phones and on an Amazon Fire tablet. It doesn't happen on a desktop PC.
Edit: I can't just use CSS to change the text to uppercase as it reverts back to however the user typed it once the form (that the textbox is on) is submitted. I need the form to submit with the text actually converted to uppercase.
$('.surname input[type=text]').keyup(function() {
var newVal = $(this).val().toUpperCase();
console.log('newVal', newVal);
$(this).val(newVal);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="surname">
<input type="text">
</div>