Possible Duplicate:
Capitalize the first letter of string in JavaScript
How do you force the first letter of the first word in a field to uppercase?
In cell B2, type =PROPER(A2), then press Enter. This formula converts the name in cell A2 from uppercase to proper case. To convert the text to lowercase, type =LOWER(A2) instead. Use =UPPER(A2) in cases where you need to convert text to uppercase, replacing A2 with the appropriate cell reference.
It's a traditional way of capitalizing titles, it's normally not to be used in articles (though nobody really prohibits it) - there Sentence case is the most widely used. In some regions it's considered more academic and thus could give a higher esteem to the writer.
On the Tools menu, click AutoCorrect Options. Click the AutoCorrect tab. Click to clear the Capitalize first letter of sentences check box. Click OK.
Asked before: How do I make the first letter of a string uppercase in JavaScript?
The correct answer:
function capitalizeFirstLetter(string)
{
return string.charAt(0).toUpperCase() + string.slice(1);
}
You can use it like this:
var myString = "hello world";
alert(capitalizeFirstLetter(myString));
And it would alert Hello world
You don't need JavaScript, it's enough with the CSS :first-letter
pseudo-element.
If you want do it via JavaScript, it has been asked before:
str.replace(/^\w/, function($0) { return $0.toUpperCase(); })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With