Uppercase Input does not work in Document.getElementById

Asked

Viewed 244 times

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 becomes capitalized thanks to transform: uppercase, but when I try to read the contents of the field through:

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

the value appears minuscule. How do I make it appear capitalized too?

1 answer

5


Try it like 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>

  • it worked blz, but I need to capture the value in another moment when I’m picking up the data from a form post: jQuery(this).serializeArray() it still brings minuscule, it would be the case to open another question?

  • @Intelidersistemas I edited the post, when capturing the value assign first in a variable converting it to uppercase. I believe this works and stores as a capital.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.