If you want to use only the first word of each sentence (not every word), use this function:
function applySentenceCase(str) {
return str.replace(/.+?[\.\?\!](\s|$)/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
Jsfiddle here
txt.substr(1).toLowerCase() , txt.substr(1).toLowerCase() txt.substr(1)