Unknown Error
Unknown Error

Reputation: 797

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

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

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

Upvotes: 6

Views: 1034

Answers (6)

Pedro Soares
Pedro Soares

Reputation: 623

Try this:

style input
input{text-transform:uppercase;}​

and onBlur make uppercase
<input onBlur="$(this).val(this.value.toUpperCase());">

That's it :)

Upvotes: 4

digitebs
digitebs

Reputation: 852

$(":input").keyup(function() {
$(this).val($(this).val().toUpperCase());
});

all yours.

Upvotes: 2

Thierry Blais
Thierry Blais

Reputation: 2858

Paste This at the bottom:

$(document).ready(function(e){
    $('input[type="text"]').on('keyup', function(){
    $(this).val(this.value.toUpperCase());
    });
});

Upvotes: 2

Alexander Corwin
Alexander Corwin

Reputation: 1157

$('form#verify').on('keyup', 'input', function(event) {
    $(this).val($(this).val().toUpperCase());
});

Upvotes: 2

Kevin B
Kevin B

Reputation: 95017

I would just convert it to uppercase in the submit event.

$("#verify input").val(function(i,val){
  return val.toUpperCase();
});

The uppercase requirement could simply be kept hidden from the user.

Upvotes: 3

Nicola Peluchetti
Nicola Peluchetti

Reputation: 76880

You could use keyup() and toUpperCase()

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

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

Upvotes: 5

Related Questions