UpperCase Input does not work in document.getElementById

2

I have an input:

<input id="id_nome" name="nome" type="text" class="form-control" style="text-transform: uppercase" autofocus required>

When I type it is uppercase thanks to transform: uppercase , but when I try to read the content of the field through:

alert(document.getElementById('id_nome').value)

The value appears minuscule. How do I get it to capitalize too?

    
asked by anonymous 13.07.2017 / 16:45

1 answer

5

Try this:

valor = document.getElementById('id_nome').value.toUpperCase();
alert(valor);
<input id="id_nome" name="nome" type="text" class="form-control" style="text-transform: uppercase" value="teste" autofocus required>
    
13.07.2017 / 16:47