I want first word first character capital of each sentence. My code only capitalizing first word, first character of para. So I want to capitalize first word, first character after full stop and exclamation mark.
Example(I want this):
- hello I haven't seen you for awhile! how are you! --> Hello I haven't seen you for awhile! How are you!
- hello I haven't seen you for awhile. how are you. --> Hello I haven't seen you for awhile. How are you.
Code:
Html Code:
<textarea autocomplete="off" cols="30" id="TextInput" name="message" oninput="myFunction()" rows="10" style="width: 100%;"></textarea>
<br><br>
<input id="FistWordFirstCharcterCapital" onclick="FistWordFirstCharcterCapital()" style="color: black;" type="button" value="First word first character capital of each sentence!" />
Javascript code
<script>
function FistWordFirstCharcterCapital() {
var string = document.getElementById("TextInput").value.toLowerCase();;
var x = string.replace(string[0], string[0].toUpperCase());
document.getElementById("TextInput").value = x;
}
</script>