How do I capitalize the first character of each word while typing in Drupal 7?
I mean, while creating a node and entering the node title, while typing something it capitalizes the first character of each word.
I know that it does this capitalization with JavaScript and I found some JavaScript function like that:
function ucFirstAllWords( str )
{
var pieces = str.split(" ");
for ( var i = 0; i < pieces.length; i++ )
{
var j = pieces[i].charAt(0).toUpperCase();
pieces[i] = j + pieces[i].substr(1);
}
return pieces.join(" ");
}
How do I apply this on Drupal for example on page.tpl.php file and/or for CCK fields.
NOTE 1: I don't want to use css, because it's just for display.
NOTE 2: I don't want to use PHP ucwords() because it doesn't affect database saving.
Some more info about what I do not want to use:
- I don't want to use PHP function
ucwords()
, I have to use PHP because it's Drupal. - I don't want to use CSS because what CSS does is display change, it doesn't change the actual value. And I don't want to use the
ucwords()
function because it doesn't affect the database. If I useucwords()
, yes it works on display (on html page) but it doesn't work for database saving. If I type 'heLLo world' it shows 'Hello World' but in database it stored as it typed 'heLLo world'.