Convert string to title case with JavaScript -


is there simple way convert string title case? e.g. john smith becomes john smith. i'm not looking complicated john resig's solution, (hopefully) kind of one- or two-liner.

try this:

function totitlecase(str) {     return str.replace(/\w\s*/g, function(txt){return txt.charat(0).touppercase() + txt.substr(1).tolowercase();}); }