Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the input to uppercase as it is being typed

I am using onkeyup="this.value=this.value.toUpperCase();"to change input text value in uppercase. This is working but my need is to change a single letter in input box without using mouse event. If i use left arrow key to move cursor backward onkeyup event gets triggered and the cursor moves to end. How do I modify this script, so that I can navigate backward using arrow keys and modify a text somewhere in between

The current code looks like this...

<h:inputText value="#{_input.response}" autocomplete="off" onmouseover="this.focus();" onkeyup="this.value=this.value.toUpperCase();"/>
like image 867
Achaius Avatar asked Sep 16 '10 08:09

Achaius


2 Answers

How about CSS:

input.upper { text-transform: uppercase; }

Remark: This will still send the value to the server as typed by the user and not uppercased.

like image 117
Darin Dimitrov Avatar answered Sep 24 '22 08:09

Darin Dimitrov


A sample could be:

<p:inputText id="nombres" 
             value="#{userController.user.nombres}" 
             style="text-transform: uppercase" />
like image 30
Juan Avatar answered Sep 23 '22 08:09

Juan