Source code:
Preview:
<script type="text/javascript">
function firstLetterUpper(theString) {
var newString = theString.toLowerCase().replace(/(^\s*\w|[\.\!\?]\s*\w)/g,function(c){return c.toUpperCase()});
return newString;
}
function convertToSentenceCase() {
var theString = document.testForm.theString.value;
//alert(theString);
var newString = firstLetterUpper(theString);
//console.log("Converted: "+newString);
document.getElementById('theString').value = newString;
}
</script>
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<form name="testForm">
<textarea cols="50" id="theString" name="theString" rows="5" style="height: 133px; margin: 0px; width: 467px;">converts text string to "sentence case" -- capitalizes the first letter of every sentence, and makes the rest lower case. helpful when you need to convert content that is in all caps.</textarea>
<button onclick="convertToSentenceCase();return false;">Convert to Sentence Case</button>
</form>
Html hilight at:
http://hilite.me/