Code, javascriptJune 10, 2009 1:47 pm
Capitalize First Letter in JavaScript
Here is a function based on excellent code from Philip M at http://www.codingforums.com/showthread.php?t=168661 that capitalizes the first letter of each word:
function caps(str){
return str.toLowerCase().replace(/\b[a-z]/g,function(w){return w.toUpperCase()});
}
The URI to TrackBack this entry is: http://jdev.blogsome.com/2009/06/10/capitalize-first-letter-in-javascript/trackback/
No comments yet.
RSS feed for comments on this post.
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>