Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to control or change all the text to upper case

I'm developing a few forms for my company to use. I consult and insert data into the database, but for standard issues I want to transform the text I enter to uppercase, How I do that?

Example of one of my forms:

I want the text fields I enter in automatically transformed to uppercase, or the data that I enter into my database already transformed to uppercase (in the case that the user doesn't enter it that way).


EDIT:

I try

$("tbCiudad").change(function() {
    $(this).val($(this).val().toUpperCase());
});

or

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

and nothing happens to that field. What am I doing wrong?

like image 998
Alejandro Hinestrosa Avatar asked Mar 06 '12 16:03

Alejandro Hinestrosa


2 Answers

$("input[type=text]").keyup(function(){
  $(this).val( $(this).val().toUpperCase() );
});
like image 104
Marius Ilie Avatar answered Oct 26 '22 13:10

Marius Ilie


You can add an event handler with javascript (or jquery if you want) to keypress or blur events of those textboxes and then apply what Jay Blanchard suggested. Something like this:

$("input[type='text']").bind("blur", null, function(e) {
    $(this).val($(this).val().toUpperCase());
});
like image 33
MilkyWayJoe Avatar answered Oct 26 '22 15:10

MilkyWayJoe