View Full Version : Capitalizing the first letter of each word

Jim Weinberg
04-16-2006, 12:40 PM
Is there a way to take a text entry from a form and make sure/change the first letter of each word is capitalized and the rest are lowercase?

04-16-2006, 01:05 PM
String.prototype.toTitleCase = function() {
var words = this.toLowerCase().split(" ");
for(var i=0;i<words.length;i++)
words[i] = words[i].charAt(0).toUpperCase() + words[i].substring(1);
return words.join(" ");
var sentence = "tHE QuiCk bRoWN Fox jUMpS oVEr THE LaZY dog";