Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make when user type in text input then automatically it will convert to uppercase in jQuery?

Tags:

jquery

Here an example my form http://jsfiddle.net/GT7fY/

How to convert all text to uppercase while user writing on the field?

like image 219
Unknown Error Avatar asked Feb 22 '12 16:02

Unknown Error


People also ask

How do you automatically set text box to uppercase?

Use keyup() method to trigger the keyup event when user releases the key from keyboard. Use toLocaleUpperCase() method to transform the input to uppercase and again set it to the input element.

How do you capitalize input in JavaScript?

The toUpperCase() method converts a string to uppercase letters. The toUpperCase() method does not change the original string.

How do you force uppercase in HTML?

As an aid to form validation we can use HTML5 input patterns to flag when an input is not valid. In the JavaScript examples, the pattern to enforce only uppercase (assuming a single word - no spaces or punctuation) is: <input ... pattern="[A-Z]*" ...>

What is toLocaleUpperCase?

The toLocaleUpperCase() method converts a string to uppercase letters, using current locale. The locale is based on the language settings of the browser. The toLocaleUpperCase() method does not change the original string.


1 Answers

You could use keyup() and toUpperCase()

$('input').keyup(function(){
   this.value = this.value.toUpperCase(); 
});

fiddle here http://jsfiddle.net/GT7fY/2/

like image 120
Nicola Peluchetti Avatar answered Nov 15 '22 08:11

Nicola Peluchetti