PDA

View Full Version : New Ext.util.Format - ucwords



Nullity
11 Jun 2007, 11:49 AM
This works just like PHP's ucwords() (http://www.php.net/manual/en/function.ucwords.php) function. Instead of capitalizing just the first letter of a string, it will capitalize the first letter of each word in a string.


Ext.apply(Ext.util.Format, {
ucwords : function(value) {
var words = value.split(/\s/);

for (i = 0; i < words.length; i++) {
words[i] = Ext.util.Format.capitalize(words[i]);
}

return words.join(' ');
}
});

So...

"this is a test"
becomes...
"This Is A Test"