Is there a simple way to convert a string to title case? E.g. john smith becomes John Smith. I\'m not looking for something complicated like John R
john smith
John Smith
Try this
String.prototype.toProperCase = function(){ return this.toLowerCase().replace(/(^[a-z]| [a-z]|-[a-z])/g, function($1){ return $1.toUpperCase(); } ); };
Example
var str = 'john smith'; str.toProperCase();