Something similar to this will work in JavaScript:
function sentenceCase(theText) {
return theText.toLowerCase().replace(/(^\s*\w|[\.\!\?]\s*\w)/g,function(c){return c.toUpperCase()});
}
Won't work perfectly in ALL cases, but, it might get you somewhere. There are a lot more elegant solutions on back-end languages, typically, though.