tags:

views:

44

answers:

3

dear all..i want my input form automatically make all character become big size.. and also without press a capslock button...i want all data which have been input into DB in capital format..what's code to make it?

+1  A: 

You can use the PHP function strtoupper.

Matthew Flaschen
+2  A: 

One simple way in jQuery is to convert the the value to uppercase after every keyup event:

$(document).ready(function(){
  $('#myfield').keyup(function() {
    var t = $(this);
    t.val(t.val().toUpperCase());
  });
});

Remember that this only changes the value in the UI on the client. When the user submits the form, it will send this uppercased value, but a malicious user could send data that was not uppercased, so you probably want to use an upcase method on your server, either in your CGI code (PHP, Perl, Java or whatever you're using), or in your SQL insert statement.

Chadwick
+1  A: 

As Matthew said, strtoupper() will work.


$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtoupper($str);
echo $str; // Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO

Using Javascript to filter something that is going into a database, is bad. What if the user decides to turn of Javascript? You can do it, but it will have to be done again when in the backend code, so it's a waste of time for something like this :)

Thomas Winsnes