Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I capitalize the first letter of an input?

Tags:

css

I'm currently trying to capitalize the very first letter from an input.

Here's what I tryed :

fieldset input
{
    text-transform:capitalize;
}

But it doesn't work the way I want, as every word is capitalized.

I also tryed this :

fieldset input:first-letter
{
  text-transform:uppercase;
}

But it seems <input /> doesn't work at all with first-letter...

Anyway, do you have any idea of how to achieve this without javascript (or as little as possible) ?

like image 706
Safirio Avatar asked Jun 15 '10 14:06

Safirio


2 Answers

JS: str.charAt(0).toUpperCase();

like image 148
Babiker Avatar answered Nov 04 '22 07:11

Babiker


Impossible. It is possible with Javascript, or by putting only the first word within a span.

like image 31
Sjoerd Avatar answered Nov 04 '22 08:11

Sjoerd